首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使webdriverIO使用指定的色度驱动器

如何使webdriverIO使用指定的色度驱动器
EN

Stack Overflow用户
提问于 2022-01-27 22:06:52
回答 1查看 1.3K关注 0票数 0

我需要我的webdriver测试使用目录中指定的chromedriver。

问题是,当我运行测试时,它总是使用设置为默认的不同的chromedriver。

命令:"wdio运行wdio.ci.conf.ts“

我得到:“色度驱动器:启动\node_modules\chromedriver\lib\chromedriver\chromedriver.exe中的ChromeDriver 97.0.4692.71”ChromeDriver 97

但是,在wdio.ci.conf.ts文件中,我将其设置为

代码语言:javascript
复制
services:[ ['chromedriver',{
        chromeDriverCustomPath:"src\\main\\cucumber-webdriver-io\\node_modules\\webdriver-manager\\selenium\\chromedriver.exe"
    }]],

在这个位置,我期待它选择一个较旧版本的铬驱动器,95.0.4638.69

我需要它运行一个较旧的版本,因为公司的Jenkins环境已经升级了Chrome。在Jenkins中,我得到了错误:

警告webdriver:由于会话未创建,状态500请求失败:此版本的ChromeDriver仅支持ChromeVersion97info,当前浏览器版本为95.0.4638.69,带有二进制路径/usr/bin/google-chrome

谢谢你的帮忙

wdio.ci.conf.ts (删除注释以使其更简短)

代码语言:javascript
复制
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

代码语言:javascript
复制
{
    "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"
    }
}
EN

回答 1

Stack Overflow用户

发布于 2022-01-28 10:43:00

漏拼

chromeDriverCustomPath >> chromedriverCustomPath

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70886382

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档