Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call non W3C standard command while in W3C mode #4073

Closed
imranazad opened this issue Jun 10, 2019 · 3 comments
Closed

Cannot call non W3C standard command while in W3C mode #4073

imranazad opened this issue Jun 10, 2019 · 3 comments

Comments

@imranazad
Copy link

imranazad commented Jun 10, 2019

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

@wswebcreation
Copy link
Member

wswebcreation commented Jun 10, 2019

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.

@imranazad
Copy link
Author

@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

minusnine pushed a commit to tebeka/selenium that referenced this issue Jul 31, 2019
Previously, `AddChrome` would quietly override `W3C` to `true`,
even if you wanted it to be `false`.

Due to a problem with Chrome, the W3C standard, and `elementIsDisplayed`,
it is necessary to be able to disable W3C mode for Chrome so that
we can call `IsDisplayed`.

This behavior appears to have started around Chrome 75.

See:
* https://stackoverflow.com/questions/56111529/cannot-call-non-w3c-standard-command-while-in-w3c-mode-seleniumwebdrivererr
* webdriverio/webdriverio#4073
@zwbetz-gh
Copy link

zwbetz-gh commented Oct 28, 2019

@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"
  ]
}

Cheddam pushed a commit to creative-commoners/MinkFacebookWebDriver that referenced this issue Feb 25, 2020
Works around newer Chrome releases enabling W3C mode by default.
See webdriverio/webdriverio#4073
Cheddam pushed a commit to creative-commoners/MinkFacebookWebDriver that referenced this issue Feb 25, 2020
Works around newer Chrome releases enabling W3C mode by default.
See webdriverio/webdriverio#4073
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants