O'Reilly logo

Selenium WebDriver Recipes in C#, Second Edition by Zhimin Zhan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 21

image

Optimization

Working test scripts are just the first test step to successful test automation, as automated tests are executed often, and we all know the application changes frequently, too. Therefore, it is important that our test scripts be

  • Fast
  • Easy to read
  • Concise

In this chapter, I show some examples to optimize test scripts.

Assert string in page_source is faster than the text

To verify a piece of text on a web page, frequently for assertion, we can use driver.PageSource or driver.FindElement(By.TagName("body")).Text. Besides the obvious different output, there are major performance differences, too. To get a text view (for a whole ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required