简体   繁体   English

如何使用 python 中的 selenium 在网站上单击继续按钮?

[英]How to click the Continue button on website using selenium in python?

I am trying to write a code that is able to auto apply on job openings on indeed.com.我正在尝试编写一个能够自动申请确实.com 上的职位空缺的代码。 I have managed to reach the last stage, however, the final click on the application form is giving me a lot of trouble.我已经到了最后一个阶段,但是,最后点击申请表给我带来了很多麻烦。 Please refer the page as below请参考以下页面在此处输入图像描述

Once logged in to my profile, I go to the relevant search page, click on the listing I am interested in and then on the final page (shown above) I am trying to click on the continue button using xpath as follows:登录到我的个人资料后,我将 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"]')

However, this gives me an error:但是,这给了我一个错误:

Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="form-action-continue"]"}

Having gone through some suggestions on the net I have even tried the following:在网上浏览了一些建议后,我什至尝试了以下方法:

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"]')))

But then this gives me a timeout error但这给了我一个超时错误

TimeoutException: Message:

Will appreciate some help on this.将不胜感激这方面的一些帮助。

From it seems, on that form there are multiple iframe s, therefore the reason for your errors.看来,在该表格上有多个iframe ,因此是您错误的原因。

You need to get the first iframe , switch to it, get the second iframe inside the first one, switch to it and only afterwards you'll be able to get the continue button.您需要获得第一个iframe ,切换到它,在第一个中获得第二个iframe ,切换到它,然后您才能获得continue按钮。

Something like this should do the trick:这样的事情应该可以解决问题:

    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()

Once I had a similar issue and standard time.sleep() until the form (or continue button) appears helped me.一旦我遇到类似的问题和标准 time.sleep() 直到出现表单(或继续按钮)对我有帮助。 Try it instead of WebDriverWait, maybe it will work.试试它而不是 WebDriverWait,也许它会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 python 中的 selenium 在网站中单击继续按钮? - How to click the Continue button within a website using selenium in python? 如何使用 python 中的 selenium 在 https://in.indeed.com/ 网站中单击继续按钮? - How to click the Continue button within https://in.indeed.com/ website using selenium in python? 如何使用 selenium - python 单击网站上的按钮? - How do I click on a button on a website using selenium - python? 如何通过python和selenium在html上单击文本为Continue的按钮 - How to click on the button with text as Continue as per the html through python and selenium 如何使用 selenium 单击按钮 - 网站 - How to click a button using selenium - website 尝试单击 paypal 上的继续按钮,python 中的 Selenium - Trying to click continue button on paypal with Selenium in python 单击使用 selenium 的网站上的按钮 - Click a button on a website using selenium 如何使用 Selenium 和 Python 在网页上单击 Continue Checkout gif 元素? - How to click on Continue Checkout gif element on webpage using Selenium and Python? 使用 Python Selenium 无法单击此网站上的登录按钮 - Can't click the login button on this website by using Python Selenium 无法在某个网站上单击使用 Python Selenium 的按钮 - Cannot click a button using Python Selenium on a certain website
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM