Member-only story
Optimize Selenium WebDriver Automated Test Scripts: Speed
Simple techniques to improve the execution speed of some automated test steps, up to 50X.

Updated 2023–12–12: a new recipe from my daughter, Use Chained Locator to Speed Up Selenium WebDriver Tests.
Working automated test scripts is only the first test step to successful test automation. As automated tests are executed often and the application changes frequently too, it is important that test scripts need to be
• Fast
• Easy to maintain
• Easy to read
In this article, I will show some techniques to optimize test scripts for speed.
The test script examples are in Ruby syntax, the techniques are applicable to other languages as well.
1. Assert text in page_source is faster than the text
To verify a piece of text on a web page, frequently for assertions, we can use
driver.page_source
or driver.find_element(:tag_name => ‘body')
.
Besides the obvious different output, there are big performance differences as well. To get a text view (for a whole page or a web control), Webdriver needs to ‘analyze’ the raw…