Element not clickable at point – Protractor – Resolved

Many times while running UI tests using Protractor or even Selenium, you come across this annoying error “WebDriverError: unknown error: Element is not clickable at point (X, Y). Other element would receive the click:” Element not clickable is NOT a problem with Protractor. It is a general problem with test automation using Selenium as well

This issue happens intermittently OR it could be persistent. So how do we fix this? If you Google the problem, you might find one solution that might work and might not work for you. So here, I have tried to give you various common solutions. Try and see which works best for you.

Element not clickable – Common Solutions

  • First and foremost, ensure that the element you want to interact with is visible. Say if you have a dropdown on your page, you might have to click the dropdown first before you interact with the element. Or say there is a sub-menu, so first you have to activate the menu to make the sub-menu visible.
Wait for Element to be visible before clicking
  • Once you have ensured that the element will be visible, wait for the element to be visible. Protractor API provides very handy ExpectedConditions. You can use wait for visibility of the element before you click it. Here is the code snippet

     
Use a more specific locator
  • If there are more than one element with the same selector you have used and the other element(s) are not visible, you need to change your locator strategy to make it more specific for the element you want to use.

     
Filter the ELement to be clicked
  • If you have multiple elements matching the locator/selector, you can use Protractor’s filter

     
Use browser actions
  • You can browser.actions() to move to an element first and then click on the element

     
USE javascript
  • You can use javascript to click an element (but before you use it, read this to understand the difference and beware of what you are doing)
  • There is another thing you can do while using javascript to click. Scroll into view Basically you have to scroll to the element before you click it.

     
  • Finally, sometimes you just need to maximize the browser window.

     

    Let me know any of the solutions work for you. Or if you tried something else, not mentioned here, so that I can include here and it will be useful to other folks.

 

Leave a Reply

Your email address will not be published. Required fields are marked *