1

One of the desired elements is in the right corner of the page, and selenium will not see it unless I manually resize the window to make the element present. If I do so, everything works fine. Selenium will find the element, click on it, and do what I want it to do. Here is my code in python

wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='15_button']")))
num_list = driver.find_element_by_xpath("//input[@id='15_button']")
num_list.click()

I have tried to resize the window by using

driver = webdriver.Chrome()
driver.set_window_size(1024, 1024)
driver.maximize_window()

which does make the element visible as the browser starts, but then Selenium gives the error

Message: unknown error: Element is not clickable at point (1206, 719). Other element would receive the click: <li id="15_input_5" class="selected">...</li>

Does anyone knows how to fix it?

Thanks a lot!

1 Answer 1

5

The error means that there is a different element covering the element you're trying to click. If Selenium tries to click on it the click will actually happen on the element that is covering it, thus it throws this error. You could use javascript to click on it, this way it doensn't matter if the element is covered or not.

num_list = driver.find_element_by_xpath("//input[@id='15_button']")
driver.execute_script("arguments[0].click();", num_list)

Another tip for you. In your code sample you are doing:

wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='15_button']")))
num_list = driver.find_element_by_xpath("//input[@id='15_button']")

The wait.until() will return the element once it has decided it is clickable. So you can get rid of the second find like so:

num_list = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='15_button']")))
2
  • You generally want to interact with the site in the way that users would. Using JS to directly click a hidden element is generally not a good practice because the user can't do that. Find out what is hiding the element and dismiss it or you may just need a short wait for the element to appear/disappear.
    – JeffC
    Jun 23, 2016 at 13:46
  • The wait.until() tip is a good one but you can go one further and add the .click() to the end of the line and not need to store the element in num_list at all.
    – JeffC
    Jun 23, 2016 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.