WebDriver, Chrome and Comet Servers


After spending about 3 hours of my day smashing my head against a really tricky little problem in WebDriver I thought I better just write a quick blog to try and warn other weary travellers.

Symptom

The WebDriver findElements() function was incredibly slow. Sometimes it wouldn’t return, and other times I would give up after 5 minutes and then suddenly I would get the response.

Cause

I was running the test on a Comet server, that is, a webpage which loads another never ending page in the background. - https://code.google.com/p/chromedriver/issues/detail?id=23

Because of this, Chrome believes that the page has never finished loading. You can notice this because the loading indicator keeps spinning in the tab.

Therefore, I believe although I may be wrong, that WebDriver keeps looking at the new data loading in the background page, and tries to determine whether those elements match. This results in the findElements() method never returning.

Solution

There are a number of solutions to this problem:

  • Use WebSocket, rather than a Comet Connection.
  • Use a different browser. Both Firefox and IE work.

Conclusion

I will never get those hours of my life back but hopefully this will save some of you some time. Good Luck with your Integration Tests!

Related Posts with Thumbnails

There are no comments yet, add one below.

Leave a Comment