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

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.