How to Solve ElementNotVisibleException in Selenium Webdriver

Hello, Guys, Welcome back to Selenium tutorial, today we will see how to handle element not visible  exception in Webdriver.

I faced this exception number of times, I struggled a lot while searching solution, and finally, I got so many solutions to solve this exception.

Before jumping to ElementNotVisibleException you should check below two posts that actually will help you to understand exception better.

How to handle Exception in Selenium

What are different exception is available in Selenium.


Full Exception document is available here-


Let us see what the reason behind this exception is:

Reasons for ElementNotVisibleException in Selenium Webdriver

Reason 1- Duplicated XPATH

While writing xpath for your application, you might have taken xpath that is matching with more than 1 element, in this case, Selenium will throw Element, not the visible exception.

If you are new to Selenium and facing issues while writing XPath then please check below post which will help you to write xpath from basic to advance level.

How to write Dynamic Xpath in Selenium Webdriver

Reason 2-

If you are trying to access some particular element on Webpage that is not currently visible, in this case also you will get the Element, not visible exception.



ElementNotVisible Exception in Selenium

ElementNotVisible Exception in Selenium

Solutions for ElementNotVisibleException in Selenium Webdriver

First Solution: Try to write unique XPATH  that matches with a single element only.


Second Solution:

Use Explicit wait feature of Selenium and wait till the element is not visible. Once it is visible then you can perform your operations.

Syntax for Explicit wait


Explanation- In above example, Selenium will wait 30 seconds until the element is not visible and once it is visible, Selenium will perform an action and will move on to the next step.

You can also give a try using JavaScript click that forcefully click on Element 


Third solution:

This actually works for me a number of times. I was struggling with the OK button in my application. Even I was writing unique xpath but still I was facing Element Not Visible exception.  I have tried below code that solved my issue.


First, I have taken the size of the element then in next statement, I took the first element from the list and I clicked on OK Button.

I have seen so many scenarios where I solved my issue using above scenario.

I also faced lots of Hidden Web Elements in my web application and used below trick which helped me a lot.Check out below youtube video for the same.


Hope this post is worth for you and your friends as well, so if you find this as useful then do share this post with your friends using sharing buttons.

Comment below if you are facing any issue.

Thanks for visiting my blog. Keep visiting. Have a nice day.

For More updates Learn Automation page

For any query join Selenium group- Selenium Group


  1. Anija
  2. Lakshmi
  3. Vanitha
  4. preetam singh
  5. mayank chincholkar
  6. Balakrishna
  7. Nikhil
  8. sumit