0% found this document useful (0 votes)
2 views

Selenium-Exceptions

The document lists various exceptions that can occur while using WebDriver, along with their descriptions and scenarios when they occur. Each exception, such as ElementNotVisibleException and NoSuchElementException, is detailed with specific conditions that trigger them. This serves as a reference for developers to understand and handle errors effectively during automated web testing.

Uploaded by

pawan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Selenium-Exceptions

The document lists various exceptions that can occur while using WebDriver, along with their descriptions and scenarios when they occur. Each exception, such as ElementNotVisibleException and NoSuchElementException, is detailed with specific conditions that trigger them. This serves as a reference for developers to understand and handle errors effectively during automated web testing.

Uploaded by

pawan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Exception Name Description When It Occurs

Thrown when an element is When attempting to interact with an


present in the DOM but is not element that is hidden (e.g., has a CSS
ElementNotVisibleException
visible, and thus cannot be property of display: none or visibility:
interacted with. hidden).
Occurs when an element is present
When trying to select an option from a
ElementNotSelectableException in the DOM but is disabled and
dropdown or list that is disabled.
cannot be selected.
Raised when an element with the When using incorrect or outdated
NoSuchElementException specified attributes cannot be locators to find elements that are not
found in the DOM. present on the current page.
Happens when the code attempts When trying to switch to a frame by
NoSuchFrameException to switch to a frame that does not name or index that is not present in the
exist. DOM.
Occurs when the code tries to
When attempting to accept or dismiss
NoAlertPresentException switch to an alert that is not
an alert that is not currently displayed.
present.
Thrown when the code attempts to When trying to switch to a window or
NoSuchWindowException switch to a window that does not tab that has been closed or never
exist. existed.
Raised when an element is no When performing actions on an
StaleElementReferenceException longer present in the DOM or has element that has been removed or
been refreshed. updated in the DOM.
Occurs when the WebDriver When performing actions after the
SessionNotFoundException session is not found or has been browser has been closed or the session
terminated. has ended.
When an operation exceeds the allotted
Thrown when a command does not
TimeoutException time, such as waiting for an element to
complete in the specified time.
appear.
A generic exception that is thrown When the WebDriver is unable to
WebDriverException when the WebDriver encounters an perform an action, often due to an
issue. unexpected browser behavior.
Raised when an element is in a When trying to interact with an element
InvalidElementStateException state that means actions cannot be that is not enabled or is in a read-only
performed on it. state.
Occurs when an element click
When attempting to click an element
command could not be completed
ElementClickInterceptedException that is covered by another element,
because another element
such as a modal or overlay.
obscures it.

Thrown when an element is When trying to interact with an element


ElementNotInteractableException present in the DOM but cannot be that is not in a state to receive actions,
interacted with. like a hidden input field.
Exception Name Description When It Occurs
Happens while interacting with the
When there is a failure in the response
ErrorInResponseException Firefox extension or the remote
from the server or browser extension.
driver server.
When the Input Method Editor (IME)
Occurs when activating the IME
ImeActivationFailedException engine cannot be activated, often in
engine has failed.
multilingual input scenarios.
Thrown when IME support is When the IME is not available on the
ImeNotAvailableException
unavailable. system or browser.
Raised when navigation causes the
When accessing a website with an
InsecureCertificateException user agent to hit a certificate
invalid or expired SSL certificate.
warning.
When providing invalid arguments to
Thrown when an argument is
InvalidArgumentException WebDriver methods, such as incorrect
invalid.
URLs.
Occurs when attempting to add a When trying to set a cookie for a domain
InvalidCookieDomainException cookie under a different domain that does not match the current
than the current URL. browsing context.
Thrown when the coordinates When providing out-of-bounds or
InvalidCoordinatesException provided to an interaction are nonsensical coordinates for mouse or
invalid. touch actions.
Raised when the session ID is not When referencing a session ID that
InvalidSessionIdException
valid. does not exist or has expired.
Thrown when the target for When attempting to switch to a non-
InvalidSwitchToTargetException
switching is invalid. existent frame or window.
When executing JavaScript via
Occurs when there is an error
JavascriptException WebDriver and the script contains
executing JavaScript.
errors.
Thrown when there is an error in When parsing or handling JSON data
JsonException
the JSON data. within WebDriver operations fails.
Raised when the attribute of an When trying to access an attribute that
NoSuchAttributeException
element could not be found. does not exist on a web element.
Occurs if the target provided to the
When attempting to move the mouse to
MoveTargetOutOfBoundsException ActionChains move() method is not
an element that is outside the viewport.
valid.
When trying to switch to a context (e.g.,
Thrown when attempting to switch
NoSuchContextException a mobile device context) that is not
to a context that does not exist.
available.
When attempting to retrieve or delete a
Raised when no cookie matching
NoSuchCookieException cookie that does not exist in the current
the given name is found.
browsing context.
Exception Name Description When It Occurs

A subclass of WebDriverException;
When trying to interact with an element
NotFoundException occurs when an element in the
that is not present in the DOM.
DOM does not exist.

Thrown when the server is not When the server fails to respond
RemoteDriverServerException responding due to improper because the capabilities described are
capabilities. not proper.
Occurs when capturing a When attempting to take a screenshot
ScreenshotException
screenshot is not possible. but the operation fails.
Raised when there is an alert, butWhen an alert is present, but WebDriver
UnhandledAlertException WebDriver is unable to perform thecannot handle it due to timing issues or
alert operation. other constraints.
When attempting to start a new
Thrown when a new session could
SessionNotCreatedException WebDriver session but the creation
not be created.
fails.
Occurs when the requested
When a command is sent to the server
command matches a known URL
UnknownMethodException that does not correspond to any known
but does not match any methods
method for the given URL.
for that URL.
Thrown when the frame or window
When attempting to switch to a frame
NoSuchShadowRootException target to be switched to does not
or window that does not exist.
exist.

You might also like