Search

Tip | Solution for SeleniumWebdriverException Element is not clickable at point X, Y



The problem


A common issue working with Chrome happens when an element loads into the DOM but the position is not fixed on the UI, so other element gets the click event and results in 'selenium.common.exceptions.WebDriverException - Element is not clickable at point (X, Y). Another element would receive the click'.


The common workaround is to wait for the element to display but also avoid Thread sleep because we don't know how much time the element needs to appear.


Selenium offers many solutions that we can use within tests like `visibilityOf` and `visibilityOfElementLocated`, but these will not always work on Chrome because even if the element is visible, it is not fully loaded and another element can receive the click event.


So how to solve this common problem in Chrome?



The solution


Simple wait and try for the element to be clickable


The above code worked well in my tests and is a simple wait and try solution.


So that is all! Now, if the element is not clickable because another element receives the click, the method retries the click for a max of 30 seconds.



Improvement


I found that each time I did a click on a website, the html of the page has changed or I expected a change, so an improvement can be wait for the html of the page to change in order to verify the click is correctly done.

Now the click event will be only valid if an html change is done. Try it and comment if it worked for you.


© 2020 Qa lemming