Search code examples
jsonrestselenium-chromedriverw3cweb-testing

Start a chromedriver session using w3c webdriver api


I'm trying to start a Chromium session using the chromedriver and w3c webdriver API, I send a POST request to http://localhost:9515/session with the body

{
    "capabilities": {
        "alwaysMatch": {
            "platformName": "linux",
            "chrome:browserOptions": {
                "binary": "/usr/bin/chromium",
                "args": ["--start-page=about:blank"]
            }
        },
        "firstMatch": [
            {"browserName": "chrome"}
        ]
    }
}

And i get the next response

{
    "sessionId": "b1a413df152017cd223dbabbcf1d2ffe",
    "status": 33,
    "value": {
        "message": "session not created exception: Missing or invalid capabilities (Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.14.47-1-MANJARO x86_64)"
    }
}

Which capabilities are missing or invalid?


Solution

  • chromedriver (as of version 2.41 at least) simply does not support the W3C WebDriver API.

    The missing capability required by chromedriver is capabilities.alwaysMatch.goog:chromeOptions.w3c: true, i.e.

    { "capabilities" : { "alwaysMatch" : { "goog:chromeOptions" : { "w3c" : true } } } }

    This is a deficiency in chromedriver. If you want to experiment with the W3C WebDriver protocol, you can use geckodriver (firefox), which has near-perfect support for the W3C WebDriver API.