How should you manage RemoteWebDriver objects when using SauceLabs with performance in mind?

StackOverflow https://stackoverflow.com/questions/20491106

سؤال

My prior experience with WebDriver was that it was always best practice to try and minimise your creation of WebDriver objects due to the overhead of spawning new browsers and, if your site is behind a login, having to log for each test you want to run.

However with SauceLabs, due to the fact they make use of the DesiredCapabilities object to set things like the tests (job) name, it feels like the only way to name your tests is to create a new RemoteWebDriver for each test and that isn't performant.

هل كانت مفيدة؟

المحلول

Sauce Labs actually supports a REST API for setting job names; You can over-write the name you set with your desired capabilities using that REST API.

A RemoteWebDriver, however, works exactly as you said: Each new WebDriver opens a new browser. Just like with a local browser, each new RemoteWebDriver connection to Sauce Labs creates a new VM. If you run all your tests against one VM, they'll all end up in the same Sauce Labs job. Each job can only have one name.

Probably the best way to test efficiently with Sauce Labs is to run multiple tests in parallel; If you really want to use the same job for all your tests in turn, you could use the "sauce:context" javascript method to give each section of that job a name, eg:

IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("sauce:context='Test The Friend Page Works'");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top