简体   繁体   English

如何使用 python 中的 selenium 在 https://in.indeed.com/ 网站中单击继续按钮?

[英]How to click the Continue button within https://in.indeed.com/ 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.登录到我的个人资料后,我将 go 转到相关搜索页面,单击我感兴趣的列表,然后在最后一页(如上所示)我尝试使用 xpath 单击继续按钮。 For the previous step (also a page on the same form), the form had multiple iframes which I was able to switch successfully.对于上一步(也是同一表单上的页面),表单有多个 iframe,我能够成功切换。 Now for the current page, I am stuck as the click function does not do anything.现在对于当前页面,我被卡住了,因为单击 function 没有做任何事情。 I have written the following code:我写了以下代码:

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()
time.sleep(5)
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()
driver.find_element_by_xpath('//*[@id="form-action-continue"]').click() 

I have tried switching the iframes again for this step but nothing happens.我已尝试为此步骤再次切换 iframe,但没有任何反应。 Even the.click() function does not do anything.即使是.click() function 也不做任何事情。

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

The element Continue is within nested <iframe> elements so you have to:元素Continue位于嵌套的<iframe>元素中,因此您必须:

  • Induce WebDriverWait for the parent frame to be available and switch to it .诱导WebDriverWait使框架可用并切换到它

  • Induce WebDriverWait for the child frame to be available and switch to it .诱导WebDriverWait使框架可用并切换到它

  • Induce WebDriverWait for the desired element to be clickable .诱导WebDriverWait使所需元素成为可点击的。

  • You can use either of the following Locator Strategies :您可以使用以下任一定位器策略

    • Using CSS_SELECTOR :使用CSS_SELECTOR

       driver.get("https://in.indeed.com/jobs?q=data%20analyst&l=Delhi&vjk=5c0bd416675cf4e5") WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "span.indeed-apply-button-label"))).click() WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[id^='indeedapply-modal-preload']"))) WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[title='Job application form']"))) WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#form-action-continue"))).click()
    • Using XPATH :使用XPATH

       driver.get("https://in.indeed.com/jobs?q=data%20analyst&l=Delhi&vjk=5c0bd416675cf4e5") WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='indeed-apply-button-label']"))).click() WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[starts-with(@id, 'indeedapply-modal-preload')]"))) WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='Job application form']"))) WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@id='form-action-continue']"))).click()
  • Note : You have to add the following imports:注意:您必须添加以下导入:

     from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
  • Browser Snapshot:浏览器快照:

确实_continue_click


Reference参考

You can find a couple of relevant discussions in:您可以在以下位置找到一些相关的讨论:

暂无
暂无

声明:本站的技术帖子网页,遵循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 在网站上单击继续按钮? - How to click the Continue button on website using selenium in python? 如何使用 Selenium 和 Python 在 https://www.deepl.com/translator 中单击复制按钮 - How to click on the Copy button within https://www.deepl.com/translator using Selenium and Python 如何使用 Selenium 和 Python 在 https://mail.protonmail.com/ 注册页面中单击创建帐户按钮 - How to click on the Create Account button within https://mail.protonmail.com/ signup page using Selenium and Python 如何使用Python和Selenium访问网站https://www.aliexpress.com/后点击并关闭横幅 - How to click and close the banner after accessing the website https://www.aliexpress.com/ using Python and Selenium 如何使用 Python Selenium 在网站 https://app.buenbit.com/dashboard 内登录 - How to login within the website https://app.buenbit.com/dashboard using Python Selenium How to locate the First name field within shadow-root (open) within the website https://www.virustotal.com using Selenium and Python - How to locate the First name field within shadow-root (open) within the website https://www.virustotal.com using Selenium and Python 如何使用Selenium和Python在URL https://maps.mapmyindia.com/direction中单击文本为“ GET ROUTES”的元素? - How to click on element with text as “GET ROUTES” within the url https://maps.mapmyindia.com/direction using Selenium and Python? 如何使用 Python 和 Selenium 点击“https://github.com/topics”上的“加载更多”按钮? - How to use Python with Selenium to click the "Load More" button on "https://github.com/topics"? 如何使用 selenium - python 单击网站上的按钮? - How do I click on a button on a website using selenium - python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM