Understanding Verify and Assert Commands in Selenium
Selenium has gained the unique status as the numero uno among the test automation tools and many developers and test managers prefer Selenium to test web-based applications across the globe. The major attractive feature of Selenium is that it is highly user-friendly and easy to learn. Along with many features, commands in Selenium make the execution of tests easier and smoother. Most important commands which are generally used are “Verify” and “Assert” commands.
Both “Verify” and “Assert” commands are used to detect whether a given input is present on a web page or not. However, there are a lot of differences between Assert and Verify commands. Hence you should have a clear understanding of Verify and assert commands.
Difference between Assert and Verify Commands
Assert Command
When you use “Assert” command the test execution will be discontinued, if it fails to meet the condition. In other words, if the Assert command fails, the execution will not go further from that point of code. Usually, this command is used in circumstances when a test should not be continued if the command fails.
Verify Command
When the Verify command is used, the test execution will continue even when the command fails. This command is generally used to check unimportant issues.
The most important thing is to use the right command in the right instance. These commands can produce adverse results when used wrongly. For example, when you use Verify instead of Assert, the test will keep on executing even when the most important thing is missing. This will reflect in the report and in the quality of the product.
Hence understanding Verify and Assert commands is necessary to work with selenium effectively. This is why selenium training tutorials are covering this part of the topic in detail and in depth. The selenium videos provided as a part of the study materials depict this portion clearly and the use of these commands will be utilised in selenium live project training which is an integral part of all Selenium training programs.