© 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_21

21. Optimization

Courtney Zhan1  
(1)
Fitzgibbon, QLD, Australia
 
Working test scripts is just the first test step to successful test automation. Automated tests are meant to be executed often, and we all know that applications change frequently, too. Therefore, it is important that your test scripts are the following:
  • Fast

  • Easy to read

  • Concise

In this chapter, we will show some examples of optimizing test scripts.

Assert Text in a Page Source Is Faster Than the Text

To verify a piece of text on a web page, frequently for assertion, you can use driver.PageSource or driver.FindElement(By.TagName("body")).Text. Besides the obvious ...

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.