most frequest exception during selenium automation code example

Example 1: exceptions in selenium

-> NoSuchElementException:
 Once I get this exception I usually check
      #1- Locator: most likely might be a locator issue
      or
      #2- Synchronization : Is my driver is running parallel to my browser.
      or
      #3- Iframe : There might be iframe to switch to 
  
  ----> StaleElementException (reference not fresh anymore)
  - We need to refresh the reference of the web element throwing this exception.
  - Page Object Design pattern solves this problem. 
  - POM Design pattern will do something called a "freshness" check for 
    the web element being used.
  - What is freshness check: re-locating web element with given locator 
    everytime we use.
 
 ---> TimeOutException
 -I get this exception only when you use explicit wait (WebDriverWait)
 -If explicit condition (element to be clickable) is not met, selenium 
   will throw this exception.
    -> ElementNotVisible
    -> ElementNotInteractable
    -> ElementNotClickable

Example 2: common exceptions in selenium

Some of the exceptions I have faced in my current project are
-> NoSuchElementException:
 Once I get this exception I usually check
      #1- Locator: most likely might be a locator issue
      or
      #2- Synchronization : Is my driver is running parallel to my browser.
      or
      #3- Iframe : There might be iframe to switch to 
  
  ----> StaleElementException (reference not fresh anymore)
  - We need to refresh the reference of the web element throwing this exception.
  - Page Object Design pattern solves this problem. 
  - POM Design pattern will do something called a "freshness" check for 
    the web element being used.
  - What is freshness check: re-locating web element with given locator 
    everytime we use.
 
 ---> TimeOutException
 -I get this exception only when you use explicit wait (WebDriverWait)
 -If explicit condition (element to be clickable) is not met, selenium 
   will throw this exception.
    -> ElementNotVisible
    -> ElementNotInteractable
    -> ElementNotClickable

Tags:

Misc Example