我正在尝试查找并单击此按钮。但我总是面对“消息:无法找到元素:”
我尝试了这个选项,但它对我没有帮助:
第一的:driver.find_element_by_xpath('//button[contains(text(), "CLAIM NOW!")]').click()
第二:driver.find_element_by_xpath('//button[@onclick="getClaim()"]').click()
第三:driver.find_element_by_css_selector('a.btn').click()
第四:driver.find_element_by_class_name('btn btn-lg btn-primary').click()
第五:driver.find_element_by_id('roll_button_container').click()
我也在使用time.sleep()
,所以它不是时间问题
操作流程:点击“立即申请!”后 将打开一个新选项卡,但在前一个选项卡中(我现在正在使用该选项卡) - 我将获得积分。我需要在项目上自动化这个
我几乎完整的代码(不能向您展示公司政策的所有内容):
from selenium import webdriver
import time
driver = webdriver.Firefox (executable_path = "/Users/USER1/Downloads/AUTOMATION/geckodriver")
driver.get("https://LINK.net/")
time.sleep(3)
driver.find_element_by_xpath('/html/body/header/nav/div/div/ul/li[5]/a').click()
time.sleep(3)
element = driver.find_element_by_xpath('/html/body/div[3]/div/div/form/div[1]/input').send_keys("login")
time.sleep(3)
el2 = driver.find_element_by_xpath('/html/body/div[3]/div/div/form/div[2]/input').send_keys("password")
time.sleep(3)
driver.find_element_by_css_selector('#loginForm > div:nth-child(3) > button:nth-child(1)').click()
time.sleep(3)
driver.find_element_by_xpath('//*[@id="test_button"]').click()
time.sleep(3)
#driver.find_element_by_xpath('//button[contains(text(), "CLAIM NOW!")]').click()
#driver.find_element_by_xpath('//button[@onclick="getClaim()"]').click()
#driver.find_element_by_class_name('btn btn-lg btn-primary').click()
#driver.find_element_by_id('roll_button_container').click()
driver.find_element_by_css_selector('a.btn').click()
time.sleep(3)
driver.quit()
while True:
time.sleep(60 * 5)
有谁可以帮我正确点击按钮?非常感谢。