Exception Handling
In this lesson, we’ll learn about the set of exceptions provided by the Selenium.
Selenium has its own set of exceptions while writing automation scripts. A programmer has to handle or throw those exceptions.
WebDriver exception #
All runtime exception classes in Selenium WebDriver come under the superclass WebDriverException
.
The most common exceptions under WebDriverException class are:
NoSuchElementException
- the element is not found during runtime usingFindBy
methodStaleElementReferenceException
- the referenced element is no longer present on the DOM pageNoSuchWindowException
- switching to an invalid windowInvalidSelectorException
- wrong or invalid selector used to find an elementElementNotSelectableException
- the element present but disabled in the DOMTimeoutException
- the element didn’t display in the specified timeNoSuchFrameException
- switching to an invalid frameNoAlertPresentException
- switching to an invalid alertElementNotVisibleException
- when an element is present in the DOM but cannot be interacted with, e.g., Hidden Elements