How can I speed up tests?

+1 vote
I use C# + NUnit+Webdriver and use [Parallelizable],

I don't use thread.sleep and implicitywait

What can I also do to make my tests running faster?


Now I have more than 300 scripts and 1 round in 1 browser takes ~4hours, what is totally too long

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
+1 vote

There are multiple parameters we have to consider.  Slowdown may not be only because of C#, slow down is very generic problem with WebDriver

Speed of the machine.

1. If you are executing it from the local machine where your own test scripts are, consider moviing it to dedicated computer.

Selenium Grid

2. Try using selenium Grid for test execution. This will distribute load and your execution can be much faster.

Element identification

3. Try to use relative xpath instead of identifying element under another element. E.g.

WebElement eleA = driver.findElement(By.id("eleA"));

WebElement eleB = eleA.findElement(By.id("eleA")); 


4. Try avoiding screenshot. As it takes your disk through lots of read and write process. If possible take screenshot of only failed test cases


5. Make sure that you have proper reporting in place. You may be adding lots of stuff into memory and this may lead to slow down as well. - This is really the least thing to consider as .net is good with memory management. Yet, we need to consider this.

Dedicated machine

6. If possible, try to use dedicated machine with browser loaded and no plugins for the browsers. This will help you speedup a lot.

Temp file

7. Try to clean up temp files more frequently. Too much of files inside %temp% folder can slowdown your execution as well.


Above are few generic solutions I have. If you have already implemented above solutions, we need to discuss about your project implementations.