DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Join us tomorrow at 1 PM EST: "3-Step Approach to Comprehensive Runtime Application Security"
Save your seat

Selenium Exceptions: The Complete List and Explanations

Understand all the different exceptions in Selenium automated testing and what they mean.

Oliver Howard user avatar by
Oliver Howard
·
Oct. 12, 18 · Tutorial
Like (5)
Save
Tweet
Share
7.73K Views

Join the DZone community and get the full member experience.

Join For Free

When running automated testing in Selenium, you will come across various exceptions and need to deal with them. Even if you work with other automation testing tools such as Katalon Studio, you may still face these types of exceptions (because Katalon Studio is built on top of Selenium). They are, however, more easily fixable than bugs or errors as they can throw a logical termination.

This article will provide you with a complete list of various exceptions in Selenium as well as the cases in which they occur. First, let’s have a look at some important information regarding the term “exception” in Selenium.

What Are Selenium Exceptions?

An exception is known as an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions. An exception is also considered as a fault.

Classification of Selenium Exceptions

Selenium exceptions are divided into two types, Checked Exceptions and Unchecked Exceptions.

  1. Checked Exceptions

Checked Exceptions are handled during the process of writing code. These exceptions are handled before compiling the code, therefore, such exceptions are examined at compile time.

2. Unchecked Exceptions

These exceptions are thrown at runtime. Unchecked exceptions are more catastrophic than compile-time exceptions as they cause problems while running automation pack in headless mode.

Complete List of Exceptions in Selenium

  1. RemoteDriverServerException: This exception is thrown when the server does not respond because the capabilities described are not correct.

  2. ScreenshotException: It is impossible to capture a screen.

  3. ScriptTimeoutException: Thrown when executeAsyncScript takes more time than the given time limit to return the value.

  4. SessionNotCreatedException: A new session could not be successfully created.

  5. SessionNotFoundException: The WebDriver is performing the action right after you quit the browser.

  6. StaleElementReferenceException: This exceptionhappens if the web element is detached from the current DOM.

  7. TimeoutException: Thrown when there is not enough time for a command to be completed.

  8. UnableToCreateProfileException: You can open a browser with certain options using profiles, but sometimes a new version of Selenium driver, the server, or the browser may not support the profiles.

  9. InvalidCoordinatesException: This happens if the coordinates offered to an interacting operation are not valid.

  10. InvalidElementStateException: This exceptionoccurs if a command cannot be finished as the element is invalid.

  11. InvalidSessionIdException: 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.

  12. InvalidSwitchToTargetException: Happens if the frame or window target to be switched does not exist.

  13. JavaScriptException: This problem happens when executing JavaScript supplied by the user.

  14. JSONException: Happens when you try to get the session capabilities where a session is not created.

Besides, you can refer to the full list of Exceptions in Selenium (Updated 2018)

Conclusion

“Exception” is a quite common term when it comes to programming, regardless of which language you use to write code. Therefore, we hope this article will be a quick reference for you to tackle exceptions in Selenium and Katalon Studio. From here, you can create robust and optimal codes in Selenium as well as Katalon Studio by handling these exceptions wisely.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Cloud-Based Transportation Management System
  • Handling Virtual Threads
  • Explaining: MVP vs. PoC vs. Prototype
  • Handling Automatic ID Generation in PostgreSQL With Node.js and Sequelize

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: