Good Luck with your Selenium Test scripts!
Introduction
Execution of the test script using Selenium API for automation are not always smooth and the test script developer encounters scenarios which are inevitable and often result in the breaking of the test script that generates unexpected test results. Such unprecedented test results or scenarios are known as exceptions. In this article we are going to discuss in detail about the 15 common Selenium exceptions which are frequently encountered by the test script developer during execution of the test automation scripts using Selenium API.
What are the exceptions in the Selenium?
The exceptions in the Selenium can be defined an uncommon or unmatched event that occurs during the execution of a test script or test suite. An exception happens at runtime error due to an unexpected event or result that influence and disturb the usual control flow in the test script. An exception is also referred to as a fault.
15 Common Selenium Exceptions:
The following are the classification of the 15 common Selenium exceptions which are frequently encountered by the test automation developers.
=> ElementClickInterceptedException:
This exception occurs when the test script in the Selenium is unable to locate the element which is coded for the click event. Such element may be concealed at the given XPath or any other locator and hence the driver is unable to locate it and hence this exception is raised on the click event. This exception can be avoided after locating the correct XPath of the element in the DOM.
=> InvalidElementStateException:
This exception occurs in the Selenium when we execute a command at the element in the DOM which is in an invalid state and as a result, that command is unable to finish the required operation.
=> UnknownMethodException:
This exception occurs in the Selenium if the requested command is matched with a known URL but at the same time, it is not matching with a methodology for the same matched URL.
=> ElementNotInteractableException:
This exception occurs when the locator is asked to locate an element in the DOM which is not intractable such as an attempt to click a disabled button, attempt to enter text into the read-only text box, etc.
=> ConnectionClosedException:
This is one of the most common Selenium exception thrown by Selenium API when the driver gets disconnected while it is executing the current script.
=> JavascriptException:
This exception occurs in the Selenium when the executing JavaScript supplied by the user has a problem in the syntaxes or coding semantics of the JavaScript
=> ElementNotSelectableException:
This exception occurs when the locator is asked to locate an element in the DOM which is actually not selectable such as an attempt to click a disabled checkbox or radio button, etc.
=> InvalidCoordinatesException:
This exception occurs when the given coordinates in the interacting operation are invalid and cannot be located by the locator in the Selenium.
=> InvalidSessionIdException:
This exception occurs in the Selenium when the given session ID is not included in the active sessions list. It implies to the fact that the session is inactive or not supported for the current operation, therefore resulting in the invalid session exception.
=> JsonException:
This exception occurs in the Selenium when the developer attempts to get the session capabilities but the session cannot be actually created.
=> InvalidSwitchToTargetException:
This exception occurs in the Selenium when the target frame or window coded to be switched, actually does not exist. Therefore, in the absence of a target frame or window, the system raises this exception.
=> MoveTargetOutOfBoundsException:
This exception occurs in the Selenium when the target provided to the ActionChains move () methodology is invalid. E.g. throwing control out of a document that results in move target out of bounds exception.
=> UnreachableBrowserException:
This exception occurs in the Selenium when the browser through the Selenium script is unable to be opened or the browser has crashed because of some known or unknown reasons.
=> NoAlertPresentException:
This exception occurs in the Selenium when the developer attempts to switch to no presented alert in the test script.
=> NoSuchAttributeException:
This exception occurs in the Selenium if the attribute of the element could not be found in the current DOM of the element selected by the locator.
Conclusion
When you are working with the Selenium WebDriver and notice any of above 15 common Selenium exceptions then don’t panic but just read out the explanation provided for these exceptions and look for the remedy. These Selenium exceptions are very commonly received by the test script developers and after recognizing these exceptions, they can be solved very easily after fixing the actual root cause or making the selection of an element and its attributes from the DOM in the most appropriate way. A smart test script never fails but always yields very efficient test result throughout the test automation.
⇓ Subscribe Us ⇓
If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:
Happy Testing!!!
Good Luck with your Selenium Test scripts!
- JUnit and Hybrid (Keyword+Data Driven) Framework – Part 1
- How to Perform Selenium Automation Using LambdaTest?
- How to create Selenium WebDriver Test using Selenium IDE? – Selenium Tutorial
- Learn JUnit annotations used for your Selenium WebDriver automation
- How to use JUnit Annotations in Selenium WebDriver Automation Script
- Installation of TestNG in Eclipse – Selenium WebDriver Tutorial
- How to handle Cookies in Selenium WebDriver
- Selenium Tutorial: Introduction to Selenium Grid
- Handling IFrames in Selenium – Selenium Tutorial
- Step by Step Guide on Database Testing using Selenium