Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Exceptions in Selenium are unavoidable. Here are 49 most common Selenium exceptions which might occur while performing Selenium Test Automation.

Himanshu Sheth
December 25, 2025
A developer will always write code keeping different scenarios in mind but there could be cases where the implementation does not work as expected. The same principle also applies to test code that is primarily written to test the existing product functionalities, unearth bugs, and make the product 100% bug free.

It is rightly said that Truth is always stranger than fiction and you would witness a lot of ‘stranger things’ when you perform Selenium test automation. These things or scenarios that you encounter when executing your test code may not be very common but the test implementation should be robust enough to handle such scenarios. These scenarios are aptly termed as exceptions and you would come across many such exceptions when using Selenium for automated browser testing.
Selenium exceptions are extensively used for handling error scenarios and avoiding web application failures. Though there are many Selenium exceptions that may happen in all the Selenium WebDriver code, some Selenium exceptions are specific to the programming languages supported by the framework e.g. Java, C#, Python, etc. This blog covers common Selenium exceptions as well as language specific exceptions, an exhaustive list that can be helpful when you encounter exceptions in your code.
If you’re new to Selenium and wondering what it is then we recommend checking out our guide – What is Selenium?
By the end of this blog, you would have a complete picture about the frequently used Selenium exceptions when executing automated browser testing related scenarios.
An exception (also referred as fault) is an unprecedented event that occurs during the process of program execution. When an exception occurs, normal program execution halts and the corresponding exception handler is executed. If there is no exception handler to handle that particular exception, the program will return to the calling function that threw the exception eventually leading to termination of the program.
As Selenium test automation is performed on different target platforms, devices, and web browsers; the behavior of the test code can vary depending on the browser type or browser version. For example, some attributes may be browser specific and an exception is thrown if the particular attribute is not present in the browser on which automated browser testing is performed. Common property names can also be browser specific which can lead to Selenium exceptions like NoSuchAttributeException if the same property is not present on the target browser.
Proper handling of exceptions is a good practice as unhandled exceptions can lead to program failure that eventually hampers the product experience. The exception object contains information regarding the type of exception, call stack, and other useful information that will be helpful for debugging & making the code more foolproof.
There are two broad categories of Selenium exceptions – Checked exceptions and Unchecked exceptions. These exceptions are classified based on the time when the exceptions are caught i.e. compile time or runtime.
Checked exceptions in Selenium test automation are handled during the process of test code implementation e.g. NoSuchAttributeException, etc. The handling of checked exceptions occurs during the compile time itself.
If some method is throwing a checked exception, it is better to define a handler that handles that particular exception.
Unchecked exceptions in Selenium test automation occur during runtime and can have severe repercussions than checked exceptions. e.g. ElementNotVisibleException, MoveTargetOutOfBoundsException, etc.
Exceptions in Java can be checked or unchecked whereas in C++, all exceptions are unchecked. Unchecked exceptions are commonly encountered in automated browser testing related scenarios as the tests span across different combinations and versions of web browsers and operating systems.
Also Read:22 Practical Tips To Test Automation With Selenium WebDriver
Watch this video to learn exception handling in Selenium, which covers different types of exceptions and how to handle them using various methods.
When performing automated browser testing on a local or remote Selenium grid, you would come across different types of exceptions. Some Selenium exceptions are specific to the programming language used for writing Selenium test automation scenarios.
Below are some of the common exceptions in Selenium that can happen in all the Selenium WebDriver code.
This scenario is commonly encountered in Selenium test automation where relevant operation (click, read, etc.) on the web element e.g. button, label, etc. is attempted but the element is hidden from the view. Another example is elements defined in HTML that have type hidden.
To avoid such Selenium exceptions, it is recommended to add a sanity check in the automated browser testing code regarding the mode of switching to the frame. Check if the frame index being used is proper. An additional wait of a few milliseconds (ms) can be added to ensure that the loading of the frame is complete.
A better practice is to verify that the web page under test is loaded using appropriate wait (in ms) in the Selenium test automation code.
This also means that an action that is dependent on a mouse position (e.g. click) was not preceded by a move operation or the move operation was provided with invalid coordinates.
To handle such an exception in Selenium test automation, it is recommended to wait for that element to be enabled before the desired action is performed on it.
This commonly happens when an XPath expression is the selector and the XPath is not valid. This results in failure to locate the intended web element.
Before calling the move method of ActionChains() class, you should always check the location we are trying to move and execute the same only if the location is present on the screen.
To handle this exception, the existence of the attribute should be checked for the browser on which testing is performed. Different property names for the same property can vary from one browser to another and inefficient handling could lead to this exception.
Another way to avoid the occurrence of this exception is by changing the attribute based on the new details of the element on the DOM.
To handle this Selenium exception, you should check whether the selector is correct and if it is correct, have an additional wait to ensure the appearance of the WebElement.
A possible solution to handle this exception is to use dynamic XPath to find the required element in a loop and break the loop once the element is located.
Watch this video to learn how to handle Stale Element Reference Exceptions in Selenium with Java.
A possible solution to handle this exception is increasing the wait time for the command to complete execution. However, an idealistic value should be chosen for the wait time else further execution can get delayed.
An additional wait can be added so that the cookie is loaded for the domain.
To handle this exception, you should download the Selenium WebDriver library that is compatible with the corresponding web browser.
Watch the video for detailed insights on how to handle common Selenium Exceptions effectively with practical solutions.
Some Selenium exceptions are specific to a particular programming language for test automation. Along with the common exceptions in Selenium that were covered in the previous section, below are Selenium exceptions specific to the Java Language:

The Selenium exceptions that are specific to C# are:
The ways in which Selenium exceptions are handled differ from one programming language to another. However, the bottom line is that Selenium exceptions should be handled as the exception provides extremely critical information.
Below is the short gist on how Selenium exceptions are handled in popular programming languages:
Python – If you are using Python for automated browser testing, the exception classes are available in selenium.common.exceptions which should be imported before using any commands from that package.
Exceptions are handled using try…except block where the try block enables you to test the code for errors, the except block helps you handle the error, and the optional finally block will be executed irrespective of whether the try block raises an error or not.
Java – Selenium exceptions are handled in Java using the try-catch method. The try block is the start of the block and the catch block contains the implementation to resolve the exception. The catch block is placed at the end of the try block. Like Python, you can also make use of the finally keyword to create a block of code that is executed whether exception occurs or not.
C# – Like Java, Selenium exceptions are handled using the try-catch statement. The try block contains code that may cause the exception. The code under the try block is executed until the code is successfully executed or an exception is thrown. The catch block contains the handlers for different exceptions.
In addition to Selenium exceptions, understanding exception handling in Cypress is also crucial for robust test automation. You can read more about effective exception-handling-in-Cypress techniques in our comprehensive guide.
Also read: Common Challenges In Selenium Automation & How To Fix Them?
Exceptions are quite common in development but they have to be handled carefully. It is important to know about the different Selenium exceptions as that helps in development of a more robust automated browser testing scripts.
Exception handling in Selenium test automation is instrumental in identifying cross browser compatibility issues pertaining specific to browser/platform/device.
What are some of the mechanisms that you have used to handle Selenium exceptions, do leave your experience in the comments section…
Happy Testing ☺
Did you find this page helpful?
More Related Hubs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance