Top 15 common Selenium exceptions you have most likely seen
Tags: selenium, opensource, tools, test
Published: 2018-10-03 08:49:28

---
title: Top 15 common Selenium exceptions you have most likely seen
published: true
description: This article will provide you with a list of common exceptions in Selenium as well as the cases in which they occur.
tags: Selenium, Opensource, tools, test

---
During every automation testing processes in <strong><a href="http://seleniumhq.com">Selenium</a></strong>, you may come across many scenarios that are not common. Those are called “exceptions,” and are inevitable when you execute your test cases even with other automation testing tools such as <strong><a href="https://www.katalon.com" target="_blank" rel="noopener">Katalon Studio</a></strong>. Nevertheless, you will achieve them if you know how to handle them properly. 

This article will provide some better understanding of exception handling.
<h2>What are Selenium exceptions?</h2>
<h3>Definition</h3>
An exception is known as an unusual or unprecedented event that occurs during the execution of a software program or application. It is a runtime error of an unexpected result or event which influence and disrupt usual program flow. An exception is also considered as a fault.
<h3>Classification of Selenium exceptions</h3>
<b>Selenium exceptions</b><span style="font-weight: 400;"> are divided into two types including Checked Exceptions and Unchecked Exceptions.</span>

<span style="font-weight: 400;">1. Checked Exceptions</span>

<span style="font-weight: 400;">Checked Exceptions are handled during the process of writing codes. These exceptions are handled before compiling the code, therefore, such exceptions are examined at the compile time.</span>

<span style="font-weight: 400;">2. Unchecked Exceptions</span>

<span style="font-weight: 400;">These exceptions are thrown at runtime. Unchecked exceptions are more catastrophic than the compile-time exception as it causes problems while running Automation pack in headless.</span>

<h2>The list of common exceptions in Selenium</h2>
<strong>1. ConnectionClosedException:</strong> This exception takes place when there is a disconnection in the driver.

<strong>2. ElementClickInterceptedException:</strong> The command could not be completed as the element receiving the events is concealing the element which was requested clicked.

<strong>3. ElementNotInteractableException:</strong> This Selenium exception is thrown when an element is presented in the DOM but it is impossible to interact with such element.

<strong>4. ElementNotSelectableException:</strong> This Selenium exception is thrown when an element is presented in the DOM but you can be able to select. Hence, it is impossible to interact with.

<strong>5. InvalidCoordinatesException:</strong> This happens if the coordinates offered to an interacting operation are not valid.

<strong>6. InvalidElementStateException:</strong> This Selenium exception occurs if a command cannot be finished as the element is invalid.

<strong>7. InvalidSessionIdException:</strong> Takes place when the given session ID is not included in the list of active sessions, which means the session does not exist or is inactive either.

<strong>8. InvalidSwitchToTargetException:</strong> Happens if frame or window target to be switched does not exist.

<strong>9. JavascriptException:</strong> This problem happens when executing JavaScript supplied by the user.

<strong>10. JsonException:</strong> Happens when you afford to get the session capabilities where the session is not created.

<strong>11. MoveTargetOutOfBoundsException:</strong> Takes place if the target provided to the ActionChains move() methodology is not valid. For example: out of document.

<strong>12. NoAlertPresentException:</strong> Happens when you switch to no presented alert.

<strong>13. NoSuchAttributeException:</strong> Occurs when the attribute of element could not be found.

<strong>14. UnknownMethodException:</strong> Thrown when the requested command matching with a known URL but not matching with a methodology for that URL.

<strong>15. UnreachableBrowserException:</strong> This Selenium exception happens if the browser is unable to be opened or have crashed because of some reasons.

<h2>Conclusion</h2>
All exceptions mentioned above are the most common cases in every automation projects. Thereby, you could handle the exceptions wisely since you grasped all perspicuous explanations. We hope you will use this article as a reference for managing exceptions and optimization codes in Selenium as well as Katalon Studio. 

Read more: <strong><a href="https://www.katalon.com/resources-center/blog/selenium-exceptions/" target="_blank" rel="noopener">Full list of exceptions in Selenium</a></strong>