-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.py
327 lines (290 loc) · 13.1 KB
/
application.py
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import keyboard
#personal info
first_name = "firstName"
last_name = "lastName"
email = ""
cover_letter = "blah blah blah"
phone_number = "911"
address = ""
headline = ""
class education(object):
name = "University of ..."
degree = "Bachelors"
major = "major"
start_month = ""
start_day = ""
start_year = ""
end_month = ""
end_day = ""
end_year = ""
my_school = education()
num_of_jobs = 3
class job(object):
title = ""
company = ""
industry = ""
summary = ""
currently_work_here = False
start_month = ""
start_day = ""
start_year = ""
end_month = ""
end_day = ""
end_year = ""
def __init__(self, title, company, industry, summary, currently_work_here,
start_month, start_day, start_year,
end_month, end_day, end_year):
self.title = title
self.company = company
self.industry = industry
self.summary = summary
self.currently_work_here = currently_work_here
self.start_month = start_month
self.start_day = start_day
self.start_year = start_year
self.end_month = end_month
self.end_day = end_day
self.end_year = end_year
job1 = job("Title", "Glassdoor", "Cybersecurity", "blah blah blah blah", True, "June", "1", "1998", "N/A", "N/A", "N/A")
job2 = job("Title", "Glassdoor", "Cybersecurity", "blah blah blah blah", True, "June", "1", "1998", "N/A", "N/A", "N/A")
job3 = job("Title", "Glassdoor", "Cybersecurity", "blah blah blah blah", True, "June", "1", "1998", "N/A", "N/A", "N/A")
#########################################################################################################################
class page_has_form(object):
def __init__(self, css_class):
self.css_class = css_class
print("css_class: " + self.css_class)
def __call__(self, driver):
form = driver.find_element_by_class_name(self.css_class) #Find form
# print(form)
if self.css_class == "modalContainer":
return form
else:
return False
class form_submitted(object):
def __init__(self, css_class):
self.css_class = css_class
print("css_class: " + self.css_class)
def __call__(self, driver):
form = driver.find_element_by_class_name(self.css_class) #Find form
# print(form)
if self.css_class != "EasyApplyConfirmation":
return form
else:
return False
def check_form(driver):
try:
phoneForm = driver.find_element_by_id('gdPhoneNumber')
except:
return 2
return 1
UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"
opts = Options()
opts.add_argument("user-agent="+UserAgent)
driver = webdriver.Chrome("/usr/local/bin/chromedriver", chrome_options=opts)
page_url = input("Enter URL: ")
driver.get(page_url)
assert "Glassdoor" in driver.title
# ad = driver.find_element_by_xpath('//*[@id="SmartBanner"]/a[1]/span/svg')
ad = driver.find_element_by_class_name('SVGInline-svg')
ad.click()
applyButton = driver.find_element_by_class_name("regToApplyArrowBoxContainer")
applyButton.click();
wait = WebDriverWait(driver, 10)
form = wait.until(page_has_form("modalContainer"))
form_type = check_form(form)
print('form type: ', form_type)
if form_type == 1:
first_name_field = driver.find_element_by_id('gdFirstName')
last_name_field = driver.find_element_by_id('gdLastName')
email_field = driver.find_element_by_id('gdEmailAddress')
cover_letter_field = driver.find_element_by_id('gdCoverLetter')
phone_number_field = driver.find_element_by_id('gdPhoneNumber')
headline_field = driver.find_element_by_id('headline')
address_field = driver.find_element_by_id('address')
#education
school_field = driver.find_element_by_id('education_._school')
degree_field = driver.find_element_by_id('education_._degree')
field_of_study_field = driver.find_element_by_id('education_._field_of_study')
start_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[1]/div[4]/div/select[1]')
start_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[1]/div[4]/div/select[2]')
start_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[1]/div[4]/div/select[3]')
end_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[1]/div[5]/div/select[1]')
end_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[1]/div[5]/div/select[2]')
end_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[1]/div[5]/div/select[3]')
#experience
title_field = driver.find_element_by_id('experience_._title')
company_field = driver.find_element_by_id('experience_._company')
industry_field = driver.find_element_by_id('experience_._industry')
summary_field = driver.find_element_by_id('experience_._summary')
check_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[5]/div/label[1]/div')
x_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[5]/div/label[2]/div')
job_start_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[6]/div/select[1]')
job_start_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[6]/div/select[2]')
job_start_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[6]/div/select[3]')
job_end_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[7]/div/select[1]')
job_end_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[7]/div/select[2]')
job_end_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[11]/div[1]/div[7]/div/select[3]')
first_name_field.clear()
first_name_field.send_keys(first_name)
last_name_field.clear()
last_name_field.send_keys(last_name)
email_field.clear()
email_field.send_keys(email)
cover_letter_field.clear()
cover_letter_field.send_keys(cover_letter)
resume = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[6]/div/button')
resume.click()
#move through path to resume file
keyboard.write('Desktop')
keyboard.press_and_release('enter')
keyboard.write('Resume')
keyboard.press_and_release('enter')
keyboard.write('resume.docx')
keyboard.press_and_release('enter')
phone_number_field.clear()
phone_number_field.send_keys(phone_number)
headline_field.clear()
headline_field.send_keys(headline)
address_field.clear()
address_field.send_keys(address)
#Education
school_field.clear()
school_field.send_keys(my_school.name)
degree_field.clear()
degree_field.send_keys(my_school.degree)
field_of_study_field.clear()
field_of_study_field.send_keys(my_school.major)
start_month_field.send_keys(my_school.start_month)
start_day_field.send_keys(my_school.start_day)
start_year_field.send_keys(my_school.start_year)
end_month_field.send_keys(my_school.end_month)
end_day_field.send_keys(my_school.end_day)
end_year_field.send_keys(my_school.end_year)
#Experience, job1
title_field.clear()
title_field.send_keys(job1.title)
company_field.clear()
company_field.send_keys(job1.company)
industry_field.clear()
industry_field.send_keys(job1.industry)
summary_field.clear()
summary_field.send_keys(job1.summary)
if (job1.currently_work_here == True):
check_field.click()
else:
x_field.click()
job_end_month_field.send_keys(job1.end_month)
job_end_day_field.send_keys(job1.end_day)
job_end_year_field.send_keys(job1.end_year)
job_start_month_field.send_keys(job1.start_month)
job_start_day_field.send_keys(job1.start_day)
job_start_year_field.send_keys(job1.start_year)
#job2, comment out if not used
add = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]')
add.click()
title_field = driver.find_element_by_xpath('(//*[@id="experience_._title"])[2]')
company_field = driver.find_element_by_xpath('(//*[@id="experience_._company"])[2]')
industry_field = driver.find_element_by_xpath('(//*[@id="experience_._industry"])[2]')
summary_field = driver.find_element_by_xpath('(//*[@id="experience_._summary"])[2]')
check_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[6]/div/label[1]/div')
x_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[6]/div/label[2]/div')
job_start_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[7]/div/select[1]')
job_start_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[7]/div/select[2]')
job_start_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[7]/div/select[3]')
job_end_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[8]/div/select[1]')
job_end_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[8]/div/select[2]')
job_end_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[2]/div[8]/div/select[3]')
title_field.clear()
title_field.send_keys(job2.title)
company_field.clear()
company_field.send_keys(job2.company)
industry_field.clear()
industry_field.send_keys(job2.industry)
summary_field.clear()
summary_field.send_keys(job2.summary)
if (job2.currently_work_here == True):
check_field.click()
else:
x_field.click()
job_end_month_field.send_keys(job2.end_month)
job_end_day_field.send_keys(job2.end_day)
job_end_year_field.send_keys(job2.end_year)
job_start_month_field.send_keys(job2.start_month)
job_start_day_field.send_keys(job2.start_day)
job_start_year_field.send_keys(job2.start_year)
#job3, comment out if not used
add = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]')
add.click()
wait = WebDriverWait(driver, 10)
title_field = driver.find_element_by_xpath('(//*[@id="experience_._title"])[3]')
company_field = driver.find_element_by_xpath('(//*[@id="experience_._company"])[3]')
industry_field = driver.find_element_by_xpath('(//*[@id="experience_._industry"])[3]')
summary_field = driver.find_element_by_xpath('(//*[@id="experience_._summary"])[3]')
title_field.clear()
title_field.send_keys(job3.title)
company_field.clear()
company_field.send_keys(job3.company)
industry_field.clear()
industry_field.send_keys(job3.industry)
summary_field.clear()
summary_field.send_keys(job3.summary)
check_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[6]/div/label[1]/div')
x_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[6]/div/label[2]/div')
job_start_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[7]/div/select[1]')
job_start_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[7]/div/select[2]')
job_start_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[7]/div/select[3]')
job_end_month_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[8]/div/select[1]')
job_end_day_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[8]/div/select[2]')
job_end_year_field = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[10]/div[3]/div[8]/div/select[3]')
if (job3.currently_work_here == True):
check_field.click()
else:
x_field.click()
job_end_month_field.send_keys(job3.end_month)
job_end_day_field.send_keys(job3.end_day)
job_end_year_field.send_keys(job3.end_year)
job_start_month_field.send_keys(job3.start_month)
job_start_day_field.send_keys(job3.start_day)
job_start_year_field.send_keys(job3.start_year)
checkbox = driver.find_element_by_class_name('theme__check___2nJhq')
checkbox.click()
submit = driver.find_element_by_xpath('//*[@id="ApplyContainer"]/div/div[2]/div[2]/div[2]/form/div[2]/div/div[2]/button')
actions = ActionChains(driver)
actions.move_to_element(submit).perform()
submit.click()
wait = WebDriverWait(driver, 10)
submitted = form = wait.until(form_submitted("modalContainer"))
if (form_type == 2):
name_field = driver.find_element_by_name("answers[0]")
email_field = driver.find_element_by_name("answers[1]")
name_field.clear()
name_field.send_keys(first_name+" "+last_name)
email_field.clear()
email_field.send_keys(email)
resume = driver.find_element_by_xpath('//*[@id="ApplyQuestions"]/div[5]/div/button')
resume.click()
#move through path to resume file
keyboard.write('Desktop')
keyboard.press_and_release('enter')
keyboard.write('Resume')
keyboard.press_and_release('enter')
keyboard.write('resume.docx')
keyboard.press_and_release('enter')
checkbox = driver.find_element_by_class_name('theme__check___2nJhq')
checkbox.click()
submit = driver.find_element_by_xpath('//*[@id="ApplyContainer"]/div/div[2]/div[2]/div[2]/form/div[2]/div/div[2]/button')
actions = ActionChains(driver)
actions.move_to_element(submit).perform()
submit.click()
wait = WebDriverWait(driver, 10)
submitted = form = wait.until(form_submitted("modalContainer"))
assert "No results found." not in driver.page_source
driver.close()
driver.quit()