-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathEasyApply.py
More file actions
91 lines (73 loc) · 2.79 KB
/
EasyApply.py
File metadata and controls
91 lines (73 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver import Keys, ActionChains
from info import *
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import random
import time
# initialize delay function which will return a random value between 3 and 7 seconds
def delay():
time.sleep(random.uniform(3,7))
def textInputQuestion(currentQuestion, driver):
# write the if statement to handle all text input questions where the answer is no
if 'Do you need' in currentQuestion:
delay()
answer = driver.find_element(by=By.TAG_NAME, value='textarea')
answer.send_keys('No')
if 'linkedin' or 'LinkedIn' in currentQuestion:
delay()
answer = driver.find_element(by=By.TAG_NAME, value='textarea')
answer.send_keys('linkedinURL')
else:
delay()
answer = driver.find_element(by=By.TAG_NAME, value='textarea')
answer.send_keys('Yes')
def continueButton(driver):
continueButton = driver.find_element(by=By.CLASS_NAME, value='ia-continueButton')
continueButton.click()
# function to handle easy apply jobs
def easyApply(driver):
# Wait for the new tab to open
WebDriverWait(driver, 10).until(lambda d: len(d.window_handles) > 1)
# Switch to the next tab (the second tab)
driver.switch_to.window(driver.window_handles[1])
print('beginning easy apply process')
# contact info page
delay()
continueButton(driver=driver)
print('clicked continue button on contact info page')
# resume page
delay()
continueButton(driver=driver)
print('clicked continue button on resumé page')
# questions page
delay()
# count number of questions with class of ia-questions-items
questions = driver.find_elements(by=By.CLASS_NAME, value='ia-Questions-item')
counter = 0
# loop through questions and answer them
numberOfQuestions = len(questions) - 1
for i in range(numberOfQuestions):
currentQuestion = questions[counter].text
# check if it is a text input question or a radio button question
if 'ia-Answer-input' in currentQuestion:
textInputQuestion(currentQuestion)
counter += 1
delay()
continueButton()
print('clicked continue button on questions page')
# add job with relevant experience
delay()
continueButton()
print('clicked continue button on add job page')
# click submit
delay()
continueButton()
print('clicked continue button on submit page')
# close current tab
driver.close()
print('closed current tab')