-1

I'm trying to find the element and click for the button "Not Now". I've tried with with css_selector, xpath, but I"m unable at all to find the proper way.

HTML:

image

Guy
  • 46,488
  • 10
  • 44
  • 88
Alex
  • 31
  • 4

1 Answers1

1

To locate and click() on the element with text as Not Now you can use the following Locator Strategy:

  • Using xpath:

    driver.find_element_by_xpath("//button[text()='Not Now']").click()
    

However, the element looks dynamic to me so you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategy:

  • Using XPATH:

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div//button[text()='Not Now']"))).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
    

Reference

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    You were right, it worked with the 2nd method. Do you have any documentation for this kind of scenarios or a place where I can learn more about? Thank you a lot! – Alex Jan 18 '20 at 09:33