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
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.