Monday, March 11, 2013

Selenium Assertions

What is an assertion in Selenium?

Assertions in Selenium verify that the state of the application conforms to what is required or expected [i.e. the expected thing is actually present]. For example make sure that a particular text is showing on a page or make sure that checkbox is checked etc.

As per Seleniumhq, all Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor". For example, you can "assertText", "verifyText" and "waitForText". When an "assert" fails, the test is aborted. When a "verify" fails, the test will continue execution, logging the failure. This allows a single "assert" to ensure that the application is on the correct page, followed by a bunch of "verify" assertions to test form field values, labels, etc.

Examples of Selenium Assertions

1. Selenium – Use Assertions to Verify the Test Output. [Link]
2. Implementing soft assertion with selenium. [Link]
3. Using assertions in Selenium. [Link]
4. Using soft assertions in TestNG. [Link]
5. Common Assertions using WebDriver. [Link]
6. Selenium WebDriver, Selenium Server and PageObjects by Example. [Link]
7. Quicker way to assert that an element does not exist. [Link]
8. Assert/VerifyElementPresent with Python and WebDriver? [Link]
9. Using assertTrue in Selenium Webdriver. [Link]
10. Selenium Webdriver - Wait for an element to load. [Link]
11. how can I check if some text exist or not in the page? [Link]