DEV Community

Cover image for Selenium Webdriver for Automation
Damon Marc Rocha II
Damon Marc Rocha II

Posted on

2 1

Selenium Webdriver for Automation

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (2)

Collapse
 
derekjhopper profile image
Derek Hopper

This is awesome. Clever use of Selenium.

Collapse
 
dmarcr1997 profile image
Damon Marc Rocha II

Thanks Derek

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay