What are some commonly encountered exceptions in Selenium?

What are some commonly encountered exceptions in Selenium?

Hello Rhian-lewis,

Some of the commonly seen exceptions in Selenium are-

  • NoSuchElementException – When no element can be located by the locator provided.

  • ElementNotVisibleException – When an element is present in the DOM but is not visible.

  • NoAlertPresentException – When we try to switch to an alert box but the targetted alert is not present.

  • NoSuchFrameException – When we try to switch to a frame but the targetted frame is not present.

  • NoSuchWindowException – When we try to switch to a window but the targetted window is not present.

  • UnexpectedAlertPresentException – When an unexpected alert blocks the normal interaction of the driver.

  • TimeoutException – When a command execution gets a timeout.

  • InvalidElementStateException – When the state of an element is not appropriate for the desired action.

  • NoSuchAttributeException – When we are trying to fetch an attribute’s value but the attribute is not correct.

  • WebDriverException – When there is some issue with the driver instance preventing it from getting launched.