© Courtney Zhan, Edited by Zhimin Zhan 2024
Z. Zhan (ed.)Selenium WebDriver Recipes in C#https://doi.org/10.1007/979-8-8688-0023-8_10

10. Assertion

Courtney Zhan1  
(1)
Fitzgibbon, QLD, Australia
 
Without assertions (often known as checks), a test script is incomplete. Test syntax frameworks, such as MS VSTest, provide an assertion syntax. Common assertions for testing web applications are
  • 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 a Page Title

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

Assert Page Text

Example web page: See Figure 10-1.

A screenshot of a text assertion. The text is text ...

Get Selenium WebDriver Recipes in C#: Practical Testing Solutions for Selenium WebDriver 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.