Exceptions in Selenium WebDriver

Before moving to Runtime Exception, you should be aware of Exception meaning.

Exception general meaning a condition that is not common, in Exceptions in Selenium WebDriver occurs many times in different scenarios let’s have a look to all exception one by one.

 

Exceptions in Selenium WebDriver

Exceptions in Selenium WebDriver

 

Exceptions in Selenium WebDriver

NoSuchElementException

This exception occurs when WebDriver is unable to identify the elements during run time. Due to wrong selector or selector, which is, not exist.
Example:-

 

ElementNotVisibleException

This Exception occurs when the element presence is in DOM, it is not visible.
Example:-
Hidden Elements, which has presence in DOM and it, is not visible. Visibility means the height and
width should be greater than zero. Hidden Elements are defined in HTML using of type=”hidden”.

 

NoSuchFrameException

This Exception occurs when the driver is switching to an invalid frame, which is not available.
Example:-

 

//frame_z is the name of the invalid frame
For frames indexing starts from Zero. Try to access the frame by providing invalid index.

NoAlertPresentException

This Exception occurs when the driver is switching to an invalid Alert, which is not available.
Example:-

//Execute this command on browser without invoking the alert.

NoSuchWindowException

This Exception occurs when the driver is switching to an invalid Window, which is not available.
Example:-

 

WebDriverException

This Exception occurs when the driver is performing the action after immediately closing the browser.
Example:-

 

SessionNotFoundException

This Exception occurs when the driver is performing the action after immediately quitting the browser.
Example:-

 

StaleElementReferenceException

This Exception occurs when the Element belongs to a different frame than the current one. The user has navigated away to another page.

Check out more exceptions here.

Thanks for visiting my blog. Please leave a comment if you have any issues in Selenium.

Keep in touch. Have a nice day 🙂

20 Comments

  1. Mahesh Chhetri
      • Mahesh Chhetri
  2. Mahesh
  3. sa
  4. Maheshwari B
  5. Senthil
  6. Senthil
  7. Satya
  8. Kannan
  9. priti