TestProject Forum
Powered by leading experts in the test automation community

Verify vs. assert in Selenium

If I understand correctly, assert will fail an entire test case, while verify will only note the failure of that condition and the test case will continue.

So with verify I get test results for multiple conditions even if one fails. One failed condition is sufficient to tell that the test will fail.

In what situations is one method preferred over the other ?

I usually use asserts as entry points into tests.
If the assertion passes, I run all verify conditions.
e.g. if I’m checking the contents of a table result from a piece of code, I would assert that the table exists, and then verify

content data.