Webdriverio: Cannot call non W3C standard command while in W3C mode

Created on 10 Jun 2019  ·  3Comments  ·  Source: webdriverio/webdriverio

Environment (please complete the following information):

  • WebdriverIO version: 4.14.4
  • Mode: WDIO Testrunner
  • If WDIO Testrunner, running sync/async: sync
  • Node.js version: 10.15.0
  • NPM version: 6.4.1
  • Browser name and version: google-chrome-stable_75.0.3770.80-1
  • Platform name and version: LINUX
  • ** "wdio-cucumber-framework": "^1.1.0", "wdio-selenium-standalone-service": "0.0.10",

Config of WebdriverIO
An example of how you configured WebdriverIO config

const path = require("path");

const isDebugMode = process.env.DEBUG === "true";

const chrome = 
    {
        browserName: "chrome",
        chromeOptions: {
            args: ["--window-size=1366,768"]
        }
    };

var capabilities = [chrome];

if(process.env.RUNNING_IN_DOCKER)
{
    capabilities = 
        [
            {
                browserName: "chrome",
                chromeOptions: {
                    args: ["--headless", "--window-size=1366,768"]
                }
            }
            // TO DO: Add headless Firefox see docker-compose.yml
        ];
} else if(process.env.ALL_BROWSERS)
{
    capabilities = 
        [
            chrome,
            {
                // set protected mode to the same value across all four zones in tools-> internet options -> security
                // also make sure zoom level is 100%
                browserName: "internet explorer"
            }
        ];
}

exports.config = {
    debug:  isDebugMode,
    execArgv: isDebugMode ? ['--inspect=9299'] : [],
    sync: true,
    maxInstances: 1,
    //maxInstances: isDebugMode ? 1 : 10,
    // Use selenium standalone server locally so we don't have a seperate selenium server in a seperate command prompt
    // Use the selenium grid via docker on TC
    services: process.env.RUNNING_IN_DOCKER ? [] : ["selenium-standalone"],
    seleniumLogs: "./logs",

    specs: [
        "./features/**/*.feature"
    ],

    exclude: [
        "./features/**/topic-page.feature"
    ],

    capabilities: capabilities,

    logLevel: "verbose",
    coloredLogs: true,
    screenshotPath: "./errorShots/",
    baseUrl: "https://*********/",
    reporters: process.env.RUNNING_IN_DOCKER ? ["spec", "teamcity"] : ["spec"],

    // Use BDD with Cucumber
    framework: "cucumber",
    cucumberOpts: {
        compiler: ["js:babel-register"], // Babel so we can use ES6 in tests
        require: [
            "./steps/given.js",
            "./steps/when.js",
            "./steps/then.js"
        ],
        tagExpression: "not @pending", // See https://docs.cucumber.io/tag-expressions/
        timeout: 30000
    },

    // Set up global asssertion libraries
    before: function before() {
        const chai = require("chai");
        global.expect = chai.expect;
        global.assert = chai.assert;
        global.should = chai.should();
    },
}

Describe the bug
Since upgrading Chrome and ChromeDriver I'm getting the following error:

Error: Promise was rejected with the following reason: unknown command: Cannot call non W3C standard command while in W3C mode at elementIdDisplayed("e88a07f5-2ca3-42ad-b458-3d66797b37f0") - isVisible.js:71:55
If you look at the changes for ChromeDriver 75.0.3770.8 http://chromedriver.chromium.org/downloads
you will see it mentions "The most noticeable change is ChromeDriver now runs in W3C standard compliant mode by default. "

I've managed to get around this by specifying w3c: false in ChromeOptions however I don't think this is the right approach. It would seem there's something somewhere that's calling a "non w3c standard" command and I'm assuming it's somewhere in webdriverio.

To Reproduce
Setup a test environment with the above details and run npm test.

Expected behavior
Tests should run without the error Cannot call non W3C standard command while in W3C mode

Most helpful comment

This is not an issue with chrome, but an issue in how you specify the options. Chrome 75 is by default W3C compliant and you must set W3C to false to be able to use the JSONWP (as mentioned in the release notes)

Try providing the options like

'goog:chromeOptions': {
        'w3c': false,
        args: ["--headless", "--window-size=1366,768"]
    },

Closing this for now as it is an issue with how you define the options instead of an issue with WebdriverIO.

All 3 comments

This is not an issue with chrome, but an issue in how you specify the options. Chrome 75 is by default W3C compliant and you must set W3C to false to be able to use the JSONWP (as mentioned in the release notes)

Try providing the options like

'goog:chromeOptions': {
        'w3c': false,
        args: ["--headless", "--window-size=1366,768"]
    },

Closing this for now as it is an issue with how you define the options instead of an issue with WebdriverIO.

@wswebcreation Thanks you're right. Can you just point me to the release notes I can't seem to find where it says to set W3C to false.

Thanks

@wswebcreation if I could thumbs up your comment 100 times I would.

I'm coming from NightwatchJS and have been investigating this error for 2 days. I was trying to run headless chromedriver in dockerized selenium hub. Adding that snippet to my nightwatch.json file did the trick. For reference for others, that section of my file now looks like:

"chromeOptions": {
  "w3c": false,
  "args": [
    "--no-sandbox",
    "--headless",
    "--window-size=1920x1080"
  ]
}
Was this page helpful?
0 / 5 - 0 ratings