mogoli
mogoli

Reputation: 2375

How do I get webdriverIO to use a specified chromedriver

I need my webdriver tests use a specified chromedriver in a directory.

The problem is that when I run the tests it always uses a different chromedriver exe that was set as a default.

Command: "wdio run wdio.ci.conf.ts"

I get : "chromedriver: Starting ChromeDriver 97.0.4692.71" ChromeDriver 97 is found in \node_modules\chromedriver\lib\chromedriver\chromedriver.exe

However in the wdio.ci.conf.ts file I set it to

services:[ ['chromedriver',{
        chromeDriverCustomPath:"src\\main\\cucumber-webdriver-io\\node_modules\\webdriver-manager\\selenium\\chromedriver.exe"
    }]],

At this location Im expecting it to pick an older version of chrome driver, 95.0.4638.69

I need it to run an older version as the corporate Jenkins environment has upgraded Chrome yet. In Jenkins I get the error:

WARN webdriver: Request failed with status 500 due to session not created: This version of ChromeDriver only supports Chrome version 97 [INFO] [0-0] Current browser version is 95.0.4638.69 with binary path /usr/bin/google-chrome

Thanks for your help

wdio.ci.conf.ts (removed the comments to be more brief)

const report = require('multiple-cucumber-html-reporter');

export const config: WebdriverIO.Config = {
    
    autoCompileOpts: {
        autoCompile: true,
        tsNodeOpts: {
            transpileOnly: true,
            project: 'tsconfig.json'
        }
        }
    },
    specs: [
        './features/**/*.feature'
    ],
    exclude: [
        // 'path/to/excluded/files'
    ],
    maxInstances: 10,
    capabilities: [{
        maxInstances: 5,
        //
        browserName: 'chrome',
        'goog:chromeOptions':{
            args: [ '--disable-dev-shm-usage', '--headless', '--no-sandbox', '--ignore-certificate-errors', '--test-type','--auth-server-whitelist=*bp.com', '--window-size=1440,1024', '--start-maximized']
        },
        acceptInsecureCerts: true,
        

    }],
    logLevel: 'info',
    bail: 0,
    baseUrl: 'http://localhost',
    waitforTimeout: 10000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    services:[ ['chromedriver',{
        chromeDriverCustomPath:"src\\main\\cucumber-webdriver-io\\node_modules\\webdriver-manager\\selenium\\chromedriver.exe"
    }]],
    framework: 'cucumber',
    reporters: ['cucumberjs-json'],
    cucumberOpts: {
        // <string[]> (file/dir) require files before executing features
        require: ['./features/step-definitions/*-steps.ts'],
        // <boolean> show full backtrace for errors
        backtrace: false,
        // <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
        requireModule: [],
        // <boolean> invoke formatters without executing steps
        dryRun: false,
        // <boolean> abort the run on first failure
        failFast: false,
        // <boolean> hide step definition snippets for pending steps
        snippets: true,
        // <boolean> hide source uris
        source: true,
        // <boolean> fail if there are any undefined or pending steps
        strict: false,
        // <string> (expression) only execute the features or scenarios with tags matching the expression
        tagExpression: '',
        // <number> timeout for step definitions
        timeout: 60000,
        // <boolean> Enable this config to treat undefined definitions as warnings.
        ignoreUndefinedDefinitions: false
    },
    onComplete: function(exitCode, config, capabilities, results) {
        report.generate({
            jsonDir: '.tmp/json/',
            reportPath: '.tmp/report/'
          });
    },
}

package.json

{
    "name": "cucumber-webdriver-io",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "wdio": "wdio run wdio.conf.ts",
        "wdio-ci": "wdio run wdio.ci.conf.ts",
        "postinstall": "rimraf -rm node_modules/wdio-html-nice-reporter/node_modules/@wdio/types"
    },
    "author": "",
    "license": "ISC",
    "description": "",
    "dependencies": {
        "cucumber": "^7.0.0-rc.0",
        "expect-webdriverio": "^3.1.4",
        "multiple-cucumber-html-reporter": "^1.18.3"
    },
    "devDependencies": {
        "@types/chai": "^4.3.0",
        "@types/node": "^17.0.12",
        "@types/webdriverio": "^5.0.0",
        "@wdio/cli": "^7.16.13",
        "@wdio/cucumber-framework": "^7.16.13",
        "@wdio/local-runner": "^7.16.13",
        "@wdio/spec-reporter": "^7.16.13",
        "@wdio/types": "^7.16.13",
        "chai": "^4.3.6",
        "chromedriver": "^97.0.2",
        "cucumber-html-reporter": "^5.5.0",
        "fs-extra": "^10.0.0",
        "ts-node": "^10.4.0",
        "typescript": "^4.5.5",
        "wdio-chromedriver-service": "^7.2.6",
        "wdio-cucumberjs-json-reporter": "^4.2.0",
        "webdriver-manager": "^12.1.8",
        "webdriverio": "^7.16.13"
    }
}

Upvotes: 1

Views: 5521

Answers (1)

mogoli
mogoli

Reputation: 2375

Missed spelled

chromeDriverCustomPath >> chromedriverCustomPath

Upvotes: 1

Related Questions