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); ...