✅ How to Handle Selenium Exception with Code? ✅
Tags: testing, tutorial, beginners, webdev
Published: 2020-06-27 07:09:43

✅ Join us - https://sendfox.com/thetestingacademy

In this video, We are going to learn How to Handle Selenium Exceptions and Top 10 Selenium Exceptions.

Exception in the Automation code is very common. ‘Exception’ as the word indicates, is a special or uncommon case.
Selenium Exception handling is a very important part of every Selenium Script and for Interview.

🚀 Notes: - https://scrolltest.com/9oPk

[![BDD](https://i.imgur.com/FGMQSWG.png
)](https://youtu.be/vG0RDOpagkw "BDD") 

### 🚀 What is an Exception?
- The unwanted event which occurs during the execution of a program or code;
- It disturbs the normal flow of the program.
- Example:  You are trying 1/0 division.
  - Arithmetic Exception 
  trying to access an element of an array which is more than the size of that array
  - ArrayOutOfBound
 Exception handling is a very important part of every Selenium Script and for Interview.

### 🚀 Top 10 Selenium Exceptions

- NotFoundException
- NoSuchWindowException
   Webdriver is trying to switch to an invalid window, which is unavailable
- NoSuchFrameException: 
   Webdriver attempts to switch to an invalid frame, which is unavailable
- NoSuchElementException
   Webdriver is not able to determine the elements during runtime, i.e., the FindBy method cannot find a particular component
- NoAlertPresentException
   Webdriver is trying to switch to an invalid alert, which is unavailable
- TimeoutException
   The command did not complete in the specified time. For example, the element didn’t display at the specified time. This is especially encountered when working with waits
- StaleElementReferenceException
  The referenced element is no longer present on the DOM page (a reference to a component is now Stale). For example, the item belongs to a different frame than the current one or the user has navigated away to another page
  Due to ?
   Navigation to another page
   DOM has refreshed
   A frame or window switch
- InvalidElementState
- ElementNotVisibleException
   In spite of the element being present in the DOM, it is not visible (can not be interactive). For example, elements defined in HTML with type =”hidden”
- ElementNotSelectableException
   An element is disabled (can not be clicked/selected) in spite of being present in the DOM
 Diagram
   For ElementNot Interactable 
    - ExpectedConditions.visibilityOfElementLocated(By.id("Passwd")));
    ExpectedConditions.elementToBeClickable
    Javascript clicks
  
- SessionNotFoundException
  Webdriver is acting immediately after ‘quitting’ the browser
------------------------------------------------------------  

-----------------------------------------------------
👪 Join our Community - http://bit.ly/learntesting2019
✅ Automation Tester Community - https://thetestingacademy.com
🐦Follow us on Twitter  - https://twitter.com/itstechmode
📖 Like us on Facebook - https://www.facebook.com/scrolltest
🎤 Listen to our Podcast - https://anchor.fm/thetestingacademy
------------------------------------------------------

#automationtesting #manualtesting #testautomation #thetestingacademy #scrolltest

--
Be sure to subscribe for more videos like this!

[![ TheTestingAcademy](https://dev-to-uploads.s3.amazonaws.com/i/r7vcy6wbvyjbk1y1uu0o.png
)](https://www.youtube.com/TheTestingAcademy?sub_confirmation=1 "TheTestingAcademy")