-2

Iam trying to find and click on this button. But i always face with "Message: Unable to locate element:"

I try this options, but its doesnt help me:

First: driver.find_element_by_xpath('//button[contains(text(), "CLAIM NOW!")]').click()

Second: driver.find_element_by_xpath('//button[@onclick="getClaim()"]').click()

Third: driver.find_element_by_css_selector('a.btn').click()

Fourth: driver.find_element_by_class_name('btn btn-lg btn-primary').click()

Firth: driver.find_element_by_id('roll_button_container').click()

Also iam using time.sleep() so its not problem with time

Flow of actions: After I click on the "Claim Now!" a new tab will open, but in the previous one (which I am on now) - I will get points. And I need to automate this on the project

My almost full code ( cant show you everything as company policy):

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)

Does anyone can help me to click on button correctly? Thanks a lot.

Button

willcrack
  • 1,794
  • 11
  • 20

1 Answers1

0

Okay, looks like that the page redirects you to a page that is full of fake ads. By clicking the link, a random ad would pop up each time. Alternatively you can run getClaim with selenium as js.

You may claim your reward by simulating the button press - running the function that the button would run - only running javascript with selenium.

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

I hope, as you would say, a "poor indian" could help you.

nagyl
  • 1,644
  • 1
  • 7
  • 18