Analysing automation script failures using Exception details is an important skill for an automation tester. Selenium and Appium are the most widely used open-source automation testing tools. If you are aware of the Selenium WebDriver Exceptions list, it would put you at ease while troubleshooting failures. As a leading test automation services company, we would like to list Selenium WebDriver exceptions and their reasons.
Unsupported Command Exception This exception is triggered when the Selenium client library sends a command which is unknown to Selenium Server. For example: If you are using a higher version of the Selenium client library which has new commands, then the lower versions of the Selenium Server can’t understand new commands which are sent from the client.
Stale Element Reference Exception The stale element reference error is a WebDriver error that occurs because the referenced web element is no longer attached to the DOM.
Every DOM element is represented in WebDriver by a unique identifying reference, known as a web element. The web element reference is a UUID used to execute commands targetting specific elements, such as getting an element’s tag name and retrieving a property of an element.
When an element is no longer attached to the DOM, i.e. it has been removed from the document or the document has changed, it is said to be stale. Staleness occurs for example when you have a web element reference and the document it was retrieved from navigates.
Reference: Mozilla MDN Web Docs
Script Timeout Exception This exception is triggered when Selenium JavaScriptExecutor command exceeds its set timeout. The default timeout is 30 seconds. However, you can extend it using Desired Capabilities.
Invalid Selector Exception If XPath/CSS Selector syntax is invalid, then it will throw Invalid Selector Error. Or if the selector’s expression is not selecting an element e.g. count(//input), then Invalid Selector Exception will be invoked.
Invalid Argument Exception The invalid argument error is a WebDriver error that occurs when the arguments passed to a command are either invalid or malformed.
Invalid argument errors can be likened to TypeErrors in JavaScript, in that they can occur for a great many APIs when the input value is not of the expected type or malformed in some way. See the type- and bounds constraints for each WebDriver command.
Comments(0)