Below are some of the common Selenium exceptions that can happen in all the Selenium WebDriver code.
The Element Click command could not be properly executed as the element that is receiving the Click command was concealed in some way.
This ‘ElementNotInteractableException’ Selenium exception is thrown when even though the targeted web element exists on the DOM, interactions with that element will hit another web element.
This Selenium Exception occurs when the target element is present on the DOM but it cannot be interacted with as the element is not selectable. For example, this exception will be thrown when interacting with the script element.
The most common type of Selenium exception, that is thrown when even though the web element is present but it is not visible. As the element is not visible, any interaction with the element is not possible. This scenario is commonly encountered in Selenium test automation where relevant operation (click, read, etc.) on the web element e.g. button, label, etc. is attempted but the element is hidden from the view. Another example is the elements defined in HTML that have type hidden.
- 401 – Unauthorized
- 400 – BadRequest
- 500 – InternalServerError
- 409 – Conflict
- 403 – Forbidden
- 405 – MethodNotAllowed
This exception is thrown if the activation of IME (Input Method Engine) has failed for some reason. The ideal manner to handle this is by checking if there is IME support available on the machine.
This Selenium exception is thrown if IME (Input Method Engine) is not available. ImeNotAvailableException is thrown for every IME-related method in cases where there is IME support that is not available on the test machine.
The usage of expired or invalid TLS certificates caused the user agent to raise a certificate warning.
The NoSuchFrameException Selenium exception is thrown when the frame to be switched-to does not exist. To avoid such Selenium exceptions, it is recommended to add a sanity check in the automated browser testing code regarding the mode of switching to the frame. Check if the frame index being used is proper. An additional wait of a few milliseconds (ms) can be added to ensure that the loading of the frame is complete.
This exception is thrown when the window target being switched-to does not exist. These scenarios can be taken care of by using window_handles in order to get the current set of active windows. Window handles can be used to perform appropriate actions on the same.
This exception is thrown when incorrect combinations/fields in browser capabilities leads to the server not sending a response. To avoid such Selenium Exceptions, it is important that the Selenium browser capabilities are thoroughly checked from the viewpoint of valid combinations of (platform + browser), (platform + browser + browser version), etc.
As the name implies, this Selenium exception is thrown when the screen capture is not possible. Such a scenario is likely in web pages/web apps where sensitive information e.g. username, password, banking information, etc. is entered by the user. In such cases, screenshot can’t be captured due to the screenshot restriction on. Here, screenshot restriction prevents the screen from being captured or recorded.
This exception occurs when the creation of a new session is not successful.
The InvalidArgumentException exception is thrown when the arguments being passed are either invalid or malformed. A better practice is to verify that the web page under test is loaded using appropriate wait (in ms) in the Selenium test automation code.
This Selenium exception is thrown when an attempt to add a cookie is for a different URL/domain than the current URL. To handle this exception, you should navigate to the correct URL where the cookie has to be added.