A good Selenium test should have as few as possible assertions.
These assertions should be
clear
simple
short
with error messages
with as little duplication as possible
Most of the Selenium Java projects use for assertions either jUnit or TestNG.
Personally, I prefer TestNG as, in the past, it offered lots of advantages over jUnit (things may be different today).
We will go through a few different examples and see different ways of creating assertions for them:
String Assertions
List<String> Assertions
List<Object> Assertions
Filtered List Assertions
Keep reading with a 7-day free trial
Subscribe to Selenium For Beginners to keep reading this post and get 7 days of free access to the full post archives.
