Sobes.tech
Junior — Middle

Can you name three examples of exceptions that may occur when working with Selenium?

sobes.tech AI

Answer from AI

Three common exceptions in Selenium:

  1. NoSuchElementException — occurs when Selenium cannot find an element on the page using the specified locator.

  2. TimeoutException — occurs if the wait (for example, via WebDriverWait) expires and the condition has not been met.

  3. StaleElementReferenceException — happens when the element you are trying to interact with no longer exists in the DOM (for example, the page has been refreshed).

Example of handling an exception in Python:

from selenium.common.exceptions import NoSuchElementException

try:
    element = driver.find_element_by_id('my-element')
except NoSuchElementException:
    print('Element not found')
Can you name three examples of exceptions that may… - sobes.tech