如何在python中使用Selenium在网站内单击“继续"按钮? [英] How to click the Continue button within a website using selenium in python?

查看:67
本文介绍了如何在python中使用Selenium在网站内单击“继续"按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个代码,该代码能够自动应用在true.com上的职位空缺上.我已经设法到达最后一个阶段,但是,最后两次单击申请表给我带来了很多麻烦.请参考以下第一页

I am trying to write a code that is able to auto apply on job openings on indeed.com. I have managed to reach the last stage, however, the final 2 clicks on the application form is giving me a lot of trouble. Please refer to the first page as below

一旦我们单击第一页上的继续,对于第二页,我首先需要向下滚动一点以从此处到达...

Once we click on continue on the first page, for the second page I first need to scroll down a bit to reach from here...

..到这里,然后最后单击应用".

..to here and then finally click on apply.

我停留在第一页上,因为单击功能无法执行任何操作.我编写了以下代码:

I am stuck on the first page, as the click function does not do anything. I have written the following code:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

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()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@id='form-action-continue']"))).click()
driver.find_element_by_xpath('//button[@id="form-action-continue"]').click()

我为此步骤尝试再次切换iframe,但没有任何反应.甚至.click()函数也不会执行任何操作.

I have tried switching the iframes again for this step but nothing happens. Even the .click() function does not do anything.

在此方面将为您提供帮助.

Will appreciate some help on this.

推荐答案

如果输入了您的值,则应该在第一次单击时进行.

This should go through the first click if your values are inputted.

driver.get("https://in.indeed.com/jobs?q=data%20analyst&l=Delhi&vjk=5c0bd416675cf4e5")
wait=WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.indeed-apply-button"))).click()
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)
cont="#form-action-continue"
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, cont))).click()

这篇关于如何在python中使用Selenium在网站内单击“继续"按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆