'assert' vs. 'verify' in Selenium
I would use an assert()
as an entry point (a "gateway") into the test. Only if the assertion passes, will the verify()
checks be executed. For instance, if I'm checking the contents of a window resulting from a series of actions, I would assert()
the presence of the window, and then verify()
the contents.
An example I use often - checking the estimates in a jqgrid: assert()
the presence of the grid, and verify()
the estimates.
I've come across a few problems which were overcome by using
assert*()
instead of
verify*()
For example, in form validations if you want to check a form element, the use of
verifyTrue(...);
will just pass the test even if the string is not present in the form.
If you replace assert with verify, then it works as expected.
I strongly recommend to go with using assert*()
.