Assert and Verify in Selenium:


  • Both assert and Verify in Selenium are used to find out if the given input on the web page exists or not.


Two things we Assert / Verify using Selenium:

  1. Verify / Assert Text Present in Web Page.
  2. Verify / Assert Element Present in Web Page.


Verify Text Present :

  • Before or after the testing phase, we need to see if specific text is displayed or not.


Assert Text Present :

  • We need to stop scripts to stop if certain assertion fails.


Verify Element Present :

  • Verify element is present or not in Web Page using in-Built methods.


Assert Element Present :

  • Assert element is present or not, If not present then then Halt process.



  • When the “assert” command fails, the test execution will be canceled. So when the Assertion fails, then all test steps are skipped / omitted after that line of code.
  • The solution to overcome this issue is to use a try-catch block.
  • We use try-catch in the block.
  • Mostly, the assurance order is used when the final result of the check value should be passed to continue in the next step.
  • In simple terms, if the assert condition is true then the program control will execute the next testing phase, but if the situation is wrong, the execution will stop and further testing phase will not be executed.
  • Failure of verification The execution of that particular test method is stopped and the test method has been marked as failed.
  • When an “assert” fails, the test will be aborted / stopped.


Example: Verify string using assertTrue.


Example of Assert:



  • When the “Verify” command fails, then execution will continue and logging the failure.
  • Mostly, the verification command is used to view non-critical things.
  • In cases where we move forward, though the end result of the check value has failed.
  • In simple words, there will be no interruption in test execution, even if the verification status is true or false.
  • Verify has been verified using the SoftAssert class.


Example of Verify:


What Is The Difference Between Assert And Verify In Selenium and Selenium Assert and Verify in selenium WebDriver and verify and assert methods in selenium