Friday, August 5, 2011

Dealing with performance issue in Test Automation

Sometime while running automation test cases we faced performance issues with AUT. Page or object fails to load before timeout which leads to false failure. Though page is not getting loaded before timeout period is an issue but we don't want our test cases to fail just because page fails to load.

Following code will wait for page to load indefinitely. Though this may not be a good approach to wait indefinitely for page to load but it helps when we are experiencing serious problem with application performance

while (true)

{

try

{

Selenium.WaitForPageLoad("5000");

break; //executed if page finished loading

}

catch (Exception)

{

//ignore the timeout exception

}

}

This could be enhanced by adding stopwatch class object to get exact time taken by page to load and have page load time in log/result file to ensure if page is taking much time to load it does not get unnoticed.