Why Do We Use Assert in Selenium?

Author: Timothy Joseph
Timothy Joseph | April 26, 2021

Why Do We Use Assert in Selenium?

Assertions are validations or checkpoints for an application and are used to indicate if an application's behavior is working as expected. They also help testers know if their test cases have passed or failed.

The reason why assertion is implemented with an automation framework or tool is to verify whether the given condition is fulfilled or not. If the condition is not completely met, then assertion(s) allow the user to simply terminate the current test case and move the execution pointer to the next text case.

Usually, Selenium does not provide any interface or class to handle the assertion, so QA engineers use TestNG to fulfill these. TestNG contains a class named "Assert" which provides a series of methods to apply assertions.

Below are some of the commonly used methods:

  • AssertTrue
  • AssertFalse
  • Fail
  • AssertEquals

Disclaimer

This publication is for informational purposes only, and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.

Post a Comment