2

I am running Selenium tests on the Chrome browser in SauceLabs and find the performance exceptionally slow.

Specifically, javascript queries (used to select objects) return in about 200ms in Sauce whereas the same queries return in about 5ms when running the test on my local machine. This 40x difference leads to total run-times that are about 5x longer in Sauce than if run local.

The code in question is basically:

return (List) driver.executeScript("return jQuery.find('.some_selector')");

Is there a known explanation for the slow response times?
Is there something I can change to speed up the javascript queries in Sauce?

Jason Days
  • 23
  • 3
  • Could you post some traces? I'd expect JS times to only depend upon the browser and hardware since they're executed directly on the DOM. My guess is that the lookup timings only *look* slower because they include the low-level WebDriver protocol calls to the remote browser, which you don't get when testing locally. – Andrew Regan Jan 29 '16 at 17:50
  • Hi Andrew. Thanks for the response. Apologies for not having quite the same depth of knowledge about traces / protocols. I did update the post to include the line of code that I'm timing. The way I time execution is by the difference of system time before/after that one line executes and writing to the console. The line is a blackbox to me, but you seem to have insight into specific differences between local execution vs remote. – Jason Days Jan 29 '16 at 19:23

1 Answers1

1

I wouldn't expect the actual JavaScript to run at a significantly different speed once on the actual browser - though of course it depends upon the SauceLabs hardware / VMs.

However, going back and forth to a remote driver over the WebDriver protocol is bound to be slower than talking to a local driver, so that will likely cover most of the difference.

I suggest this is an inevitable result of running via Selenium Grid and especially of running against remote browsers, potentially on a variety of hardware. Hopefully the flexibility of this approach is worth the slight performance hit, and of course the difficulty of comparing local vs. remote.

Andrew Regan
  • 5,087
  • 6
  • 37
  • 73
  • Thank you again Andrew. Looks like for now I'll have to sniff out and remove any superfluous queries. If there is any update from the Sauce side, I'll post it here. Best, Jason – Jason Days Jan 30 '16 at 04:38