0

I have been refactoring my test framework to not use DesiredCapabilities since they are now Obsolete and there isn't a way to get rid of the warnings. I'm running into an issue when passing Options to BrowserStack where the OS and OSVersion options are not being set unless I pass them as capabilities. The test still runs on BS but it's on a seemingly random OSVersion.

Has anyone found a way to pass these DesiredCapabilities as Options without triggering the Deprecation warnings?

I've found a couple sources referencing modification to capabilities.ChromeOptions but those threads don't make sense to me and don't offer working solutions. Almost everything searched is just building them together with desired capabilities feeding into chromeoptions when calling the driver, but this still throws the Deprecation warning.. Any help is appreciated.

Edit: BS recommend doing it this way, which I've tried and am getting the reported result.. seems the os and osversion must be passed in via desiredcapabilities:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("browserVersion", "76.0");
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("os", "Windows");
browserstackOptions.Add("osVersion", "10");
browserstackOptions.Add("resolution", "1920x1080");
browserstackOptions.Add("local", "false");
browserstackOptions.Add("seleniumVersion", "3.5.2");
browserstackOptions.Add("userName", "USERNAME");
browserstackOptions.Add("accessKey", "ACCESS_KEY");
capabilities.setCapability("bstack:options", browserstackOptions);

It's getting the Browser and Browser Version right, but failing to select the desired os and osVersion if they're not passed as DC.

LoflinA
  • 310
  • 3
  • 17
  • https://stackoverflow.com/questions/46786043/chromedrivercapabilities-capabilities-is-deprecated – IPolnik Aug 15 '19 at 20:07
  • Above answer does not solve the problem for BrowserStack. This may need to just be a bug reported to them. – LoflinA Aug 15 '19 at 20:53

1 Answers1

1

You can pass the OS and OS version capabilities using Browser specific Options as below-

ChromeOptions options = new ChromeOptions();

options.AddAdditionalCapability("osVersion", "Sierra", true);
options.AddAdditionalCapability("os", "OS X", true);
options.AddAdditionalCapability("browser_version", "67", true);

driver = new RemoteWebDriver(new Uri("http://<your_username>:<your_access_key>@hub-cloud.browserstack.com/wd/hub/"),options.ToCapabilities());

For more examples, you can refer the samples available here - https://github.com/abhi291096/CSharp314

Do take a look at their capability generator for more details.

Ozone17
  • 118
  • 5