Selenium WebDriver Exceptions


Analysing automation script failures using Exception details is an important skill for an automation tester. Selenium and Appium are most widely used open-source automation testing tools. If you are aware of 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 its reasons.

Unsupported Command ExceptionThis exception is triggered when Selenium client library sends a command which is unknown to Selenium Server. For example: If you are using a higher version of Selenium client library which has new commands, then the lower versions of Selenium Server can't understand new commands which are sent from the client.

Stale Element Reference ExceptionThe 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 retreiving a property off 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 ExceptionThis 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 ExceptionIf 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 ExceptionThe 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.


Leave a Reply

Your email address will not be published. Required fields are marked *