-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtest.py
96 lines (65 loc) · 3.08 KB
/
test.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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
driver = webdriver.Chrome('./chromedriver.exe')
driver.get('https://www.indeed.com/')
driver.find_element_by_xpath('/html/body/div[2]/div/section/div/div[2]/button').click()
driver.find_element_by_xpath('//*[@id="text-input-what"]').send_keys('software engineer')
whereElem = driver.find_element_by_xpath('//*[@id="text-input-where"]')
whereElem.send_keys(Keys.CONTROL, 'a')
whereElem.send_keys('91101')
whereElem.submit()
jobList = driver.find_elements_by_class_name('iaP')
action = ActionChains(driver)
# Get the main page with window handles
main = driver.window_handles[0]
# Open new window for each jobs found
for i in range(1, len(jobList)):
jobList[i].click()
# assign new window just opened
jobWin = driver.window_handles[i]
# Switch to new window
driver.switch_to.window(jobWin)
driver.implicitly_wait(10)
# Click apply job
driver.find_element_by_class_name('jobsearch-IndeedApplyButton-contentWrapper').click()
#iframe = driver.find_element_by_xpath('/html/body/iframe')
#WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe[contains(@src,'resumeapply')]")))
parentIframe = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH,"//iframe[contains(@id,'modal-iframe')]")))
driver.switch_to.frame(parentIframe)
childIframe = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH,"//iframe[contains(@src,'resumeapply')]")))
driver.switch_to.frame(childIframe)
#driver.find_element_by_xpath('//*[@id="input-applicant.name"]').send_keys('[email protected]')
#driver.find_element_by_xpath('//*[@id="form-action-cancel"]').click()
# Close the current tab
#driver.close()
#driver.switch_to.window(main)
#driver.implicitly_wait(10)
driver.find_element_by_xpath('//*[@id="indeedApplyButtonContainer"]/span/div[1]/button/div').click()
"""
#driver.find_element_by_class_name('jobsearch-IndeedApplyButton-contentWrapper').click()
driver.find_element_by_xpath('//*[@id="indeedApplyButtonContainer"]/span/div[1]/button/div').click()
#Get popup window
main_window = None
while not main_window:
main_window = driver.current_window_handle
popup_window = None
while not popup_window:
for handle in driver.window_handles:
if handle != main_window:
popup_window = handle
break
#iframe = driver.find_element_by_xpath('/html/body/iframe')
iframe = driver.find_element_by_css_selector('body > iframe')
title = driver.title
print(title)
driver.switch_to_frame
driver.implicitly_wait(10)
#nameElem = driver.find_element_by_id('input-applicant.name')
#nameElem.send_keys('Huey Phan')
driver.find_element_by_id('input-applicant.email').send_keys('[email protected]')
"""