Skip to end of metadata
Go to start of metadata

With our support for the latest Selenium version, 3.11.0, Sauce Labs also now supports the W3C-compliant Selenium capabilities and protocol that will be released with upcoming Selenium versions. Some of the features being implemented are only available when using the W3C protocol, and the upcoming Selenium versions will include extended capabilities that are not backwards-compatible with previous Selenium versions. Sauce Labs is offering a Beta support program to test these new features, and to help prepare for the transition to the upcoming Selenium versions. In addition to feedback about updating your scripts as described in this topic, we'd like to hear your feedback about the overall changes to Selenium in our dedicated Slack channel. If you would like to apply to be part of the Beta Slack channel, please contact our Product Team

W3C Protocol for Appium

Sauce labs will launch a separate initiative to support the W3C protocol for Appium. Appium 1.8.0, released on April 20th, 2018 offers full support for W3C. We are not aware of any existing issues with using W3C capabilities in Appium tests, however we will launch a separate initiative to offer Beta support for W3C capabilities for Appium tests on the Sauce Labs cloud. 

Updating Desired Capabilities

You'll need to make a few changes to the desired capabilities of your existing Selenium test scripts to use the new W3C capabilities in Selenium 3.11.0.

Capability

Edit

version

Change the name of the capability to browserVersion and set the version to latest, or use one of these browser versions that is compatible with the W3C protocol:

  • Firefox - v.53+
  • Chrome - v.61+
  • Internet Explorer 11

sauce:options

A new capability in which you must include all the capabilities that are specific to Sauce Labs.

For example, if you wanted to specify your Sauce username, access key, and the Selenium version in your test, you would set the sauce:options like this:

"sauce:options": {"username": "myuser", "accesskey": "XXXXXXXX", "seleniumVersion": "3.11.0"}

Set a Value for seleniumVersion

When using sauce:options, you must include the seleniumVersion capability, and set a value for it, as shown in the example. If you don't include this capability, your test will fail with an error like Sauce VMs failed to start the browser or device Details Browser = IE11, Windows 7 - metadata shows “sauce:options”: “oversized non-string {…}.

The capabilities that are specific to Sauce Labs are:

    • accessKey
    • appiumVersion
    • avoidProxy
    • build
    • captureHtml
    • chromedriverVersion
    • commandTimeout
    • crmuxdriverVersion
    • customData
    • disablePopupHandler
    • extendedDebugging
    • firefoxAdapterVersion
    • firefoxProfileUrl
    • idleTimeout
    • iedriverVersion
    • maxDuration
    • name
    • parentTunnel
    • passed
    • prerun
    • preventRequeue
    • priority
    • proxyHost
    • public
    • recordLogs
    • recordScreenshots
    • recordVideo
    • restrictedPublicInfo
    • screenResolution
    • seleniumVersion
    • source
    • tags
    • timeZone
    • tunnelIdentifier
    • username
    • videoUploadOnPass

seleniumVersion

This should now be set only within the sauce:options capability. For tests running on Google Chrome, seleniumVersion does not need to be set at all.

platform

Change the capability name to platformName

browserName

For testing on Google Chrome browsers, change chrome to googlechrome

chromeOptions

For tests on Google Chrome, the W3C capability must be set as an experimental option:

ChromeOptions chOpts = new ChromeOptions(); 
chOpts.setExperimentalOption("w3c", true);

This capability needs to be sent if testing in Chrome with W3C.
Additionally, the "w3c" value needs to be set as a boolean value and not a string. For example, it would be set to true in Java and True in Python, not "true."

DesiredCapabilities.firefox

Change to new.FireFoxOptions(). DesiredCapabilities.firefox is being deprecated, and when you use this capability with Selenium 3.11, you'll see a message: "INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()"

IE Driver Version

Set 'iedriverVersion' to 3.12.0

Edited Script Example

These two Java snippets show a comparison between an original script, and the version after it has been edited to use the new W3C capabilities.

Before

DesiredCapabilities caps = DesiredCapabilities.firefox();
 
caps.setCapability("platform", "Windows 10");
caps.setCapability("version", "latest");
caps.setCapability("username", "someuser");
caps.setCapability("accessKey", "00000000-0000-0000-0000-000000000000");
caps.setCapability("seleniumVersion", "3.11.0");
caps.setCapability("name", "my test case");
 
WebDriver driver = new RemoteWebDriver(new URL("https://ondemand.saucelabs.com/wd/hub"), caps);

After

DesiredCapabilities caps = DesiredCapabilities.firefox();

caps.setCapability("platformName", "Windows 10");
caps.setCapability("browserVersion", "latest");
 
MutableCapabilities sauceCaps = new MutableCapabilities();
sauceCaps.setCapability("username", "someuser");
sauceCaps.setCapability("accessKey", "00000000-0000-0000-0000-000000000000");
sauceCaps.setCapability("seleniumVersion", "3.11.0");
sauceCaps.setCapability("name", "my test case");
caps.setCapability("sauce:options", sauceCaps);
        
WebDriver driver = new RemoteWebDriver(new URL("https://ondemand.saucelabs.com/wd/hub"), caps);

Checking for Use of New Capabilities

You can check to see whether your tests are running under the new W3C protocol.

  1. Go to the Test Details page for your test in the Sauce Labs web interface.
  2. Click the Commands tab.
  3. Select the first Post command, which will be Post /session.
  4. Under the screenshot of the command, in the Parameters section, you will see the capabilities that were used in the test. If that line begins with desiredCapabilities, you are running the non-W3C version. If it begins with capabilities, you are running the new W3C-compliant version. 

Script Editing Demo

In this demo you'll see how to modify a basic Selenium script written in Java to be compliant with the new W3C protocol.

  • No labels