![](/img/trans.png)
[英]How to click the Continue button within a website using selenium in python?
[英]How to click the Continue button on website using selenium in python?
我正在尝试编写一个能够自动申请确实.com 上的职位空缺的代码。 我已经到了最后一个阶段,但是,最后点击申请表给我带来了很多麻烦。 请参考以下页面
登录到我的个人资料后,我将 go 转到相关搜索页面,单击我感兴趣的列表,然后在最后一页(如上所示)我尝试使用xpath
单击continue
按钮,如下所示:
driver.get("https://in.indeed.com/jobs?q=data%20analyst&l=Delhi&vjk=5c0bd416675cf4e5")
driver.find_element_by_xpath('//*[@id="apply-button-container"]/div[1]/span[1]').click()
driver.find_element_by_xpath('//*[@id="form-action-continue"]')
但是,这给了我一个错误:
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="form-action-continue"]"}
在网上浏览了一些建议后,我什至尝试了以下方法:
driver.get("https://in.indeed.com/jobs?q=data%20analyst&l=Delhi&vjk=5c0bd416675cf4e5")
driver.find_element_by_xpath('//*[@id="apply-button-container"]/div[1]/span[1]').click()
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="form-action-continue"]')))
但这给了我一个超时错误
TimeoutException: Message:
将不胜感激这方面的一些帮助。
看来,在该表格上有多个iframe
,因此是您错误的原因。
您需要获得第一个iframe
,切换到它,在第一个中获得第二个iframe
,切换到它,然后您才能获得continue
按钮。
这样的事情应该可以解决问题:
frame_1 = driver.find_element_by_css_selector('iframe[title="Job application form container"')
driver.switch_to.frame(frame_1)
frame_2 = driver.find_element_by_css_selector('iframe[title="Job application form"]')
driver.switch_to.frame(frame_2)
continue_btn = driver.find_element_by_css_selector('#form-action-continue')
continue_btn.click()
一旦我遇到类似的问题和标准 time.sleep() 直到出现表单(或继续按钮)对我有帮助。 试试它而不是 WebDriverWait,也许它会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.