loading...
Cover image for Selenium Webdriver for Automation

Selenium Webdriver for Automation

dmarcr1997 profile image Damon Marc Rocha II ・2 min read

So I recently wanted to create an application to automate the job application process. This project is still a work in progress and was really just meant to be a break from what I have been working on. Using selenium and Monster's easy application process, I got my program to apply to various speed-apply jobs.

Setup

First I imported requests and webdriver from selenium. Then got the monster job URL for software jobs in texas and passed it into my chrome driver

import requests
from selenium import webdriver
URL = 'https://www.monster.com/jobs/search/?q=Software-Developer&where=texas'
driver = webdriver.Chrome(chromedriver_location)
driver.get(URL)
Enter fullscreen mode Exit fullscreen mode

Then the program logged me in using the code below:

driver.find_element_by_tag_name("ul a").click()
driver.find_element_by_id("email").send_keys("email")
driver.find_element_by_id("password").send_keys("password")
driver.find_element_by_id("btn-login").click()
Enter fullscreen mode Exit fullscreen mode

Job Application

When I first started this I tried to go through each application and have the program fill in my information and apply. This worked well for one job but the driver was slower than the code and caused some issues. So I decided to just select the speed-apply jobs and apply to these. However, the issue then arose that the page some times had different numbers of jobs so I implemented the solution below:

for num in range(0, 50):
    try:
        jobs = driver.find_elements_by_tag_name('h2 a')
        jobs[num].click()
    except:
        driver.find_element_by_class_name('mux-search-results').click()
        jobs = driver.find_elements_by_tag_name('h2 a')
        jobs[num].click()
    try:
        apply = driver.find_element_by_id('speedApply')
        if apply:
            apply.click()
            print(f"applied to job {num}")
    except:
        print(f"job {num}")
        print("Gotta do more")
Enter fullscreen mode Exit fullscreen mode

In this code, I go through 50 jobs(Sometimes). If there are no more jobs the program then presses the more jobs button. Once these results are loaded the program will try to continue through the process. This works for the most part but as of now, I am running into issues with some of the speed applies.

With this, I have successfully applied for a handful of jobs on Monster using Selenium and python code.

Posted on by:

dmarcr1997 profile

Damon Marc Rocha II

@dmarcr1997

Hi, my name is Damon Rocha. I am a flatiron software engineering graduate. I have been coding for 4 years now.

Discussion

pic
Editor guide
 

This is awesome. Clever use of Selenium.