Search code examples
seleniumselenium-webdriverassertionsverify

Java Selenium WebDriver code to implement Verify instead of Assert


I am not able to understand how to write Java code to implement Verify. I am always seeing the code to implement Assert but not for Verify. I know for Assert, we need to write the code as below:

Assert.assertTrue()

or

Assert.assertEquals() etc.

But what about Verify? I want to verify the title of my application once the user is logged into the application by using verify. How can I do this?


Solution

  • You must use the TestNG framework which only supports Assert statements. It doesn't support Verify statements. You can visit the following URL for TestNG Javadoc:

    http://testng.org/javadocs/

    From http://seleniumonlinetrainingexpert.wordpress.com/2012/11/20/what-is-the-difference-between-assert-and-verify-in-selenium/

    When Assertion fails all test steps after that line of code are skipped When a “verify” fails, the test will continue executing and logging the failure.

    If you want to use Verify statements then you will have to use the Junit framework.