-2

我正在尝试查找并单击此按钮。但我总是面对“消息:无法找到元素:”

我尝试了这个选项,但它对我没有帮助:

第一的: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)

有谁可以帮我正确点击按钮?非常感谢。

按钮

4

1 回答 1

0

好的,看起来该页面会将您重定向到一个充满虚假广告的页面。通过点击链接,每次都会弹出一个随机广告。或者,您可以getClaim使用 selenium 作为js.

可以通过模拟按钮按下 - 运行按钮将运行的功能 -仅使用 selenium 运行 javascript来索取奖励。

cmd = "getClaim()"
driver.execute_script(cmd)

正如您所说,我希望“可怜的印度人”可以帮助您。

于 2020-12-31T11:45:56.807 回答