CHAPTER 10

image

Assertion

Without assertions, often known as checks, a test script is incomplete. Common assertions for testing web applications are the following:

  • Page title (equals)
  • Page text (contains or does not contain)
  • Page source (contains or does not contain)
  • Input element value (equals)
  • Display element text (equals)
  • Element state (selected, disabled, displayed)

Assert page title

Assert.AreEqual("TestWise IDE", driver.Title);

Assert page text

Figure 10-1 shows an example web page.

9781484217412_Fig10-01.jpg

Figure 10-1. An example web page

Get Selenium WebDriver Recipes in C#, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.