What is the Difference between Assert and Verify commands in Selenium ?

Both of them check for condition true or false.
But what happens at the time of failure of these ?
When  “verify” fails, : When “verify” fails, the test will continue executing and logging the failure.
Verifies and Continues execution 
When “assert” fails : When an “assert” fails, the test will be aborted. 
Asserts and STOPS if fail

Must Read : Absolute path vs relative path in Selenium
Assert:  While we check for the presence of an element is present on the web page . If the condition is true that is if element is present then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.
Assert.assertEquals(28, multiply(10, 3));
In the above example we want to assert that the product of "10 X 3" equals to "28" or not.
Beacuse it is not, so the condition fails and the next statement never gets executed
Verify:  Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halt i.e. any failure during verification would not stop the execution and all the test steps would be executed.
  • Assert statements are used in TestNG
  • Verify statements are used in Junit framework.                                                                           
                                                                                      
       Previous                                                     Next





       Links to useful posts:

·         Abstraction
·         Method Overriding
·         Method Overloading
·         Instance Variables 
·         Java Applets
·         Pop ups and Alerts
·         Absolute path
·         Relative path
·         Annotations
·         JSP Vs Servlet
·         Absolute path Vs Relative path
·         Testng Annotations - part 1
·         Model-based testing (MBT)
·         Big Data Testing
·         Cloud Testing
·         TDD Test Driven Development
·         Verification vs Validation
·         Software testing types
·         Risk Management