Describe some of the exceptions available in Selenium with python?


There are multiple exceptions available in Selenium that are thrown whenever any unexpected situations occur or any of the methods yield error. BaseException is the class from where all the objects of Python are derived.

The exceptions that are generated by default are from the interpreter or the built in functions. The exceptions are generally created while we develop a new code and there is a good possibility of errors. Some of the exceptions of Selenium are listed below −

  • ElementNotVisibleException – This exception is generated when an element is available in DOM, but it is invisible. Hence no actions can be done on it.

  • ElementNotInteractableException - This exception is generated when an element is available in DOM. However, when performing action on it, another element is getting affected.

  • ElementClickInterceptedException - This exception is generated when an element click command could not be achieved. This is because the element which is receiving the event is hiding the element that requested the click operation.

  • ElementNotSelectableException - This exception is generated when an element which is unselectable is made an attempt to select

  • InsecureCertificateException - This exception is generated when a navigation is responsible to hit a certificate warning. This resulted in creating an expired and incorrect certificate of TLS.

  • ErrorInResponseException - This exception is generated due to an error on the server side.

  • ImeActivationFailedException - This exception is generated due to a failed activation of IME engine.

  • ImeNotAvailableException - This exception is generated if IME support is unavailable.

  • InvalidElementStateException - This exception is generated if a command remains incomplete as the element state is not valid.

  • InvalidArgumentException - This exception is generated if a command argument is not valid.

  • InvalidCoordinatesException - This exception is generated if the coordinates for operations are not valid.

  • InvalidCookieDomainException - This exception is generated for adding a cookie under a different domain and not in the present URL.

  • InvalidSwitchToTargetException - This exception is generated when the target window or frame to be switched is nonexistent.

  • InvalidSelectorException - This exception is generated if the selector to identify an element fails to get a WebElement.

  • MoveTargetOutOfBoundsException - This exception is generated when the target to the method ActionsChains move() is not valid.

  • InvalidSessionIdException - This exception is generated if the provided session id is either inactive or nonexistent and is not a part of the active sessions.

  • NoSuchFrameException - This exception is generated when the target frame to be switched is nonexistent.

  • NoAlertPresentException - This exception is generated when the target alert to be switched is nonexistent.

  • NoSuchCookieException - This exception is generated when there is no matching cookie amongst the cookies of the present browsing active content.

  • NoSuchAttributeException - This exception is generated when an element attribute is missing.

  • UnableToSetCookieException - This exception is generated when a driver is not able to set a cookie.

  • NoSuchWindowException - This exception is generated when the target window to be switched is nonexistent.

  • TimeoutException - This exception is generated when a command execution does not complete in a time range.

  • StaleElementReferenceException - This exception is generated when an element reference is currently stale.

  • UnexpectedTagNameException - This exception is generated when an assisting class did not find the proper web element.

  • UnexpectedAlertPresentException - This exception is generated when an unexpected alert has come up.

Updated on: 29-Jul-2020

292 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements