Table of Contents
Enroll in Selenium Training

To many programmers, there is no strangeness when they hear the term “exception”. To testers, in particular, this is inevitable. Exceptions are scenarios that occur during the execution of a program that disrupts the normal flow and creates exception objects. Nevertheless, achieving them is not too difficult or impossible. We will discuss these Common Exceptions in Selenium subsequently.

Therefore, in this article, let’s have a look at Common Exceptions in Selenium WebDriver and their brief explanations one by one so that you could find the most suitable ways to handle them. We will cover the below topics in this article:-

  • What are Selenium Exceptions?
    • Classification of Selenium Exceptions
  • What are the common exceptions in Selenium WebDriver?

What are Selenium Exceptions?

An exception is known as an unusual or unprecedented event that occurs during the execution of a software program/ application. It is a runtime error of an unexpected result or event which influences and disrupts usual program flow. We also consider an exception as a fault.

Classification of Selenium Exceptions

We can divide the Selenium exceptions into two types, including Checked Exceptions and Unchecked Exceptions.

Checked Exceptions

We can handle the Checked Exceptions during the process of writing codes. We handle these exceptions before compiling the code. Therefore, we examine such exceptions at the compile time.

Unchecked Exceptions

These exceptions throw at runtime. Unchecked exceptions are more disastrous than the compile-time exception as it causes problems while running Automation pack in headless.

Common Exceptions in Selenium WebDriver

UPDATED: Katalon Studio currently supports executing test cases from Selenium, TestNG, or JUnit projects. You can easily migrate them to a destination Katalon Studio project. Migrating test scripts from Selenium and TestNG/JUnit to Katalon Studio help users to eliminate the need to start everything from scratch. We can reuse the Test cases after the migration, and you can enjoy Katalon features to execute and maintain them.

Common Exceptions in Selenium WebDriver

Here is a list of some of the most popular exceptions in Selenium WebDriver, which you may or may not encounter.

  1. TimeoutException: Thrown when there is not enough time for a command to complete.
  2. UnableToCreateProfileException: You can open a browser with specific options using profiles, but sometimes a new version of Selenium Driverserver or browser may not support the profiles.
  3. UnableToSetCookieException: This occurs if a driver is unable to set a cookie.
  4. UnexpectedAlertPresentException: This Selenium exception happens when there is the appearance of an unexpected alert.
  5. UnexpectedTagNameException: Happens if a support class did not get a web element as expected.
  6. InvalidCookieDomainException: This happens when you try to add a cookie under a different domain rather than the current URL.
  7. InvalidCoordinatesException: This happens if the coordinates offered to an interacting operation are not valid.
  8. InvalidElementStateException: This Selenium exception occurs if a command cannot finish as the element is invalid.
  9. InvalidSessionIdException: Takes place when the given session ID does not include in the list of active sessions, which means the session does not exist or is inactive either.
  10. InvalidSwitchToTargetException: Happens if a frame or window target to switch does not exist.
  11. ElementClickInterceptedException: The command could not complete as the element receiving the events is concealing the element which was requested clicked.
  12. ElementNotInteractableException: This Selenium exception gets thrown when an element is present in the DOM, but it is impossible to interact with such an element.
  13. NoAlertPresentException: Happens when you switch to no presented alert.
  14. NoSuchAttributeException: This occurs when we can’t find the attribute of the element.
  15. NoSuchContextException: Happens in mobile device testing and is thrown by ContextAware.
  16. NoSuchCookieException: This exception gets thrown if there is no cookie matching with the given pathname found amongst the associated cookies of the current browsing context’s active document.
  17. NoSuchElementException: Happens if we can't find an element.
  18. NoSuchFrameException: Takes place if frame target to be switch does not exist.
  19. NoSuchWindowException: This occurs if the window target to be switch does not exist.
  20. NotFoundException: This exception is a subclass of WebDriverException. It happens when an element on the DOM doesn't exist.


Exceptions are unavoidable during the execution of any test automation projects. By explaining the most famous exceptions that we have caught in Selenium, we want to create quick documentation for you to make your tests more resilient. Hopefully, this could also help you learn how to work effectively with exceptions in other testing tools.

Complete Guide for Test Automation Frameworks
Complete Guide for Test Automation Frameworks
Previous Article
Experience API Testing in an all-new way with Katalon Studio 5.8
Experience API Testing in an all-new way with Katalon Studio 5.8
Next Article

Similar Articles