CHAPTER 20
Leverage Programming
The reason that Selenium WebDriver quickly overtakes other commercial testing tools (typically promoting record-and-playback), in my opinion, is embracing programming, which offers the flexibility needed for maintainable automated test scripts.
In this chapter, I show some examples that use some programming practices to help our testing needs.
Throw exceptions to fail test
Although Visual Studio Unit Testing Framework or NUnit framework provides most of the assertions needed, throwing exceptions can be useful too, as shown below.
string osPlatform = System.Environment.OSVersion.Platform.ToString();System.Console.WriteLine(osPlatform); ...
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.