Configuring Selenium tests to run on Sauce Labs is simple. The basic change is to switch from using a local Selenium driver to using a remote driver pointed at
ondemand.saucelabs.com, specifying your Sauce Labs account credentials and desired browser configuration.
If you wanted to run a Selenium test on Selenium locally, you would initiate a driver for the browser you want to test against like this.
IWebDriver driver = new FirefoxDriver();
To run a test on a remote service like Sauce Labs, all you need to change is your
driver definition, and make sure that the
sauce_endpoint variable includes your Sauce
IWebDriver driver; DesiredCapabilities desiredCapability = DesiredCapabilities.Firefox()// set the desired browser desiredCapability.SetCapability("platform", "Windows 7"); // operating system to use driver = new RemoteWebDriver(new Uri("http://YOUR_USERNAME:YOUR_ACCESS_KEY@ondemand.saucelabs.com:80/wd/hub");
To find your Sauce Labs access key:
Once you have your tests set up to run in the Sauce cloud, you need to define the platform, browser, and version you want the test to run against, which is where
DesiredCapabilities come into play.
DesiredCapabilities desiredCapability = DesiredCapabilities.Firefox()// set the desired browser desiredCapability.SetCapability("platform", "Windows 7"); // operating system to use
You can manually enter the values you want for the desired capabilities, or you can use our handy Platform Configurator to generate the
caps values for any combination of platform, browser, and browser version.