Top 15 common Selenium exceptions you have most likely seen
TestingNews
Posted on October 3, 2018
During every automation testing processes in Selenium, you may come across many scenarios that are not common. Those are called “exceptions,” and are inevitable when you execute your test cases even with other automation testing tools such as Katalon Studio. Nevertheless, you will achieve them if you know how to handle them properly.
This article will provide some better understanding of exception handling.
What are Selenium exceptions?
Definition
An exception is known as an unusual or unprecedented event that occurs during the execution of a software program or application. It is a runtime error of an unexpected result or event which influence and disrupt usual program flow. An exception is also considered as a fault.
Classification of Selenium exceptions
Selenium exceptions are divided into two types including Checked Exceptions and Unchecked Exceptions.
1. Checked Exceptions
Checked Exceptions are handled during the process of writing codes. These exceptions are handled before compiling the code, therefore, such exceptions are examined at the compile time.
2. Unchecked Exceptions
These exceptions are thrown at runtime. Unchecked exceptions are more catastrophic than the compile-time exception as it causes problems while running Automation pack in headless.
The list of common exceptions in Selenium
1. ConnectionClosedException: This exception takes place when there is a disconnection in the driver.
2. ElementClickInterceptedException: The command could not be completed as the element receiving the events is concealing the element which was requested clicked.
3. ElementNotInteractableException: This Selenium exception is thrown when an element is presented in the DOM but it is impossible to interact with such element.
4. ElementNotSelectableException: This Selenium exception is thrown when an element is presented in the DOM but you can be able to select. Hence, it is impossible to interact with.
5. InvalidCoordinatesException: This happens if the coordinates offered to an interacting operation are not valid.
6. InvalidElementStateException: This Selenium exception occurs if a command cannot be finished as the element is invalid.
7. InvalidSessionIdException: Takes place when the given session ID is not included in the list of active sessions, which means the session does not exist or is inactive either.
8. InvalidSwitchToTargetException: Happens if frame or window target to be switched does not exist.
9. JavascriptException: This problem happens when executing JavaScript supplied by the user.
10. JsonException: Happens when you afford to get the session capabilities where the session is not created.
11. MoveTargetOutOfBoundsException: Takes place if the target provided to the ActionChains move() methodology is not valid. For example: out of document.
12. NoAlertPresentException: Happens when you switch to no presented alert.
13. NoSuchAttributeException: Occurs when the attribute of element could not be found.
14. UnknownMethodException: Thrown when the requested command matching with a known URL but not matching with a methodology for that URL.
15. UnreachableBrowserException: This Selenium exception happens if the browser is unable to be opened or have crashed because of some reasons.
Conclusion
All exceptions mentioned above are the most common cases in every automation projects. Thereby, you could handle the exceptions wisely since you grasped all perspicuous explanations. We hope you will use this article as a reference for managing exceptions and optimization codes in Selenium as well as Katalon Studio.
Read more: Full list of exceptions in Selenium
Posted on October 3, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.