Additional Keys Are Supported For Setting Desired Capabilities W.R.T execution on cloud environment:
1. Account Name: username=<AccountName>
2. AccessKey : accessKey=<AccessKey>
Example:
/*Below snippet does belong to C# conventions*/
private void setRemoteWebDriverForCloudSauceLabs()
{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.SetCapability(CapabilityType.BrowserName, this.browser);
desiredCapabilities.SetCapability(CapabilityType.Version, this.version);
desiredCapabilities.SetCapability(CapabilityType.Platform, this.platform);
desiredCapabilities.SetCapability("username", this.userName);
desiredCapabilities.SetCapability("accessKey", this.accessKey);
desiredCapabilities.SetCapability("name", this.executedFrom + " - " + this.jobName + " - " + this.buildNumber + " - " + TestContext.CurrentContext.Test.Name);
Uri commandExecutorUri = new Uri("http://ondemand.saucelabs.com/wd/hub");
this.driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilities);
}
The same url for saucelabs connection can also contain username and accesskey. For example:
Uri commandExecutorUri = new Uri("http://<username>:<accessKey>@ondemand.saucelabs.com:80/wd/hub");
/*For BrowserStack*/
private void setRemoteWebDriverForCloudBrowserstack()
{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.SetCapability("browser", this.browser);
desiredCapabilities.SetCapability("browser_version", this.browser_version);
desiredCapabilities.SetCapability("os", this.os);
desiredCapabilities.SetCapability("os_version", this.os_version);
desiredCapabilities.SetCapability("browserstack.user", this.browserstack_user);
desiredCapabilities.SetCapability("browserstack.key", this.browserstack_key);
Uri commandExecutorUri = new Uri("http://hub.browserstack.com/wd/hub/");
this.driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilities);
}
How to get list of desiredcapabilities:
SauceLabs: Set Environment Using Utility Given At PlatformConfigurator
1. PlatformConfigurator: https://docs.saucelabs.com/reference/platforms-configurator
1. Account Name: username=<AccountName>
2. AccessKey : accessKey=<AccessKey>
Example:
/*Below snippet does belong to C# conventions*/
private void setRemoteWebDriverForCloudSauceLabs()
{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.SetCapability(CapabilityType.BrowserName, this.browser);
desiredCapabilities.SetCapability(CapabilityType.Version, this.version);
desiredCapabilities.SetCapability(CapabilityType.Platform, this.platform);
desiredCapabilities.SetCapability("username", this.userName);
desiredCapabilities.SetCapability("accessKey", this.accessKey);
desiredCapabilities.SetCapability("name", this.executedFrom + " - " + this.jobName + " - " + this.buildNumber + " - " + TestContext.CurrentContext.Test.Name);
Uri commandExecutorUri = new Uri("http://ondemand.saucelabs.com/wd/hub");
this.driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilities);
}
The same url for saucelabs connection can also contain username and accesskey. For example:
Uri commandExecutorUri = new Uri("http://<username>:<accessKey>@ondemand.saucelabs.com:80/wd/hub");
/*For BrowserStack*/
private void setRemoteWebDriverForCloudBrowserstack()
{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.SetCapability("browser", this.browser);
desiredCapabilities.SetCapability("browser_version", this.browser_version);
desiredCapabilities.SetCapability("os", this.os);
desiredCapabilities.SetCapability("os_version", this.os_version);
desiredCapabilities.SetCapability("browserstack.user", this.browserstack_user);
desiredCapabilities.SetCapability("browserstack.key", this.browserstack_key);
Uri commandExecutorUri = new Uri("http://hub.browserstack.com/wd/hub/");
this.driver = new RemoteWebDriver(commandExecutorUri, desiredCapabilities);
}
How to get list of desiredcapabilities:
SauceLabs: Set Environment Using Utility Given At PlatformConfigurator
1. PlatformConfigurator: https://docs.saucelabs.com/reference/platforms-configurator
No comments:
Post a Comment