Matt Matt - 3 months ago 35x
jQuery Question

Selenium / python - cannot click on an element

I am trying to use python and selenium to go to a website to collect some data, but I can't even get past the initial popup asking me to click an Accept button to agree to the terms of use! The website is here

I can see that the 'Accept' link/div has an id and I've tried using find_element_by_xpath and selecting the id then attempting to click, but that doesn't work.

I've also tried using ActionChains to navigate to the button and clicking, but that doesn't work either. The error it returns is element is not clickable at point...

There appears to be some jquery/javascript going on in the background which is proving difficult to deal with!

Any help would be greatly appreciated.


The trick is to wait for the "Accept" button to become clickable, move to the button and click:

from selenium import webdriver
from selenium.webdriver import ActionChains
from import By
from import WebDriverWait
from import expected_conditions as EC

driver = webdriver.Firefox()

wait = WebDriverWait(driver, 10)
accept = wait.until(EC.element_to_be_clickable((By.ID, "btnPopupAccept")))

actions = ActionChains(driver)