3

I have a set of UI tests (around 40 in total) that are written in C# using Selenium WebDriver + ChromeDriver + NUnit.

Till the last week, it took around 40-50 minutes to execute the set. Then suddenly the execution time was tripled and now takes around 2 hours 30 minutes. There were no changes in tests and test framework itself.

After the issue appeared, I updated Selenium WebDriver library and ChromeDriver to the latest version (Selenium 2.48.2.0). It didn't help me at all.

Our web application that tests are testing is written using BackboneJS. I had a talk with our developers. They claimed that there were no significant changes to the code itself.

The most interesting part is that we already had this situation when tests started running a bit slower, but the time difference was not so huge.

Investigations and conclusions I did:

  • there is no dependency on browsers and browserdrivers. The same slowness is when running tests in Firefox or Chrome;
  • there is no dependency on machines where tests are running. The same slowness is on different PCs;
  • there is no dependency on environments. I checked 2 different ones (different servers and configurations). All the same for our web application;
  • I also did all possible tricks suggested on the Internet (disabling proxy in settings, although it was not used. Turning off hardware acceleration in Chrome, although it's always ON when selenium creates a browser instance. Tried different versions of WebDriver, etc.). Nothing really helps;
  • I also made sure we are targeting "Any CPU" to avoid issues described here.

I installed dotTrace and profiled one of the tests. Almost all time of test execution is taken by selenium methods such as FindElement or GetText. Digging down the methods I found out that System.Net.HttpWebRequest.GetResponce takes almost all time.

I run out of ideas "why?". The page is loaded completely and fast. Firstly, I thought that there was some issue with frontend javascript, maybe async code etc., did profiling in Devtools, nothing suspicious.

I guess there might be something failing in communication of Selenium and BackboneJS. Something that is not noticeable in UI, but definitely has influence.

This is very frustrating and critical for us. If anyone has any ideas of what might have influence or had similar issues, please share. I would appreciate any ideas and experience.

Thank you.

Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
Kate
  • 31
  • 3
  • The Web site is being deployed how often? [Performance issues in IIS possibly](http://bradkingsley.com/enable-caching-in-iis-to-speed-performance/) – lloyd Dec 01 '15 at 05:03
  • We deploy our web application every night. There seems to be no issue with iis. The site works like a flash when navigating manually. All pages are loaded very fast. But for Selenium "GetResponse" is stuck even when the page has been loaded a long time ago, even when Selenium is getting the same information over again. – Kate Dec 01 '15 at 23:21
  • Might need some code on how you're setting implicit waits for elements. – lloyd Dec 01 '15 at 23:24
  • The code is pretty simple: "IWebElement htmlElement = driver.FindElement(by);" where "FindElement" is OpenQA.Selenium.IWebElement FindElement(OpenQA.Selenium.By by). But it's not a spesific problem for FindElement. All Selenium metods work slow. – Kate Dec 02 '15 at 01:25
  • There's a easy way to check [initial load](http://stackoverflow.com/questions/13386471/fixing-slow-initial-load-for-iis). Just rerun the same test a second time. You could load up a earlier version of the site to confirm what the developers are saying such as [Chrome F12](https://developer.chrome.com/devtools). – lloyd Dec 02 '15 at 22:07
  • Rollback to a earlier version of Chrome as well. – lloyd Dec 02 '15 at 22:11
  • @lloyd, thanks for your advises, but as I wrote tests are running slow in Firefox as well. The version and type of the browser don't matter. Also, it happened once that tests were running slow in the morning and started running fast in the evening. So there is no issue with the code, as it was not changed during the day. There must be something between Selenium-server communication. – Kate Dec 07 '15 at 00:50
  • Even during the debug mode, when whole page is 100% loaded (I did profiling with F12 Dev Tools as well), selenium stills checks one page for 1 minute, all because of getting http response. For example, I have a page with 25 rows. I have to find them all and get their text to compare. So with min code it will be 25 FindElement + 25 GetText. Each operation takes 1 second as a result analyzing just one absolutely loaded page takes 50-70 seconds, that is extremely slow. Most of the time is taken by System Get http response, when users do not experience any slowness in manual mode. – Kate Dec 07 '15 at 00:51
  • Possible duplicate of [DNS Lookup in simple C#/asp.net ajax call is extremely slow](http://stackoverflow.com/questions/2959746/dns-lookup-in-simple-c-asp-net-ajax-call-is-extremely-slow) – Paul Sweatte Nov 04 '16 at 23:22

0 Answers0