我需要我的网络驱动程序测试使用目录中指定的chromedriver。
问题是,当我运行测试时,它总是使用一个不同的chromedriver.exe,它被设置为默认值。
命令:";wdio运行wdio.ci.conf.ts";
我得到:";chromedriver:起始chromedriver 97.0.4692.71〃;ChromeDriver 97位于\node_modules\ChromeDriver\lib\ChromeDriver\ChromeDriver.exe 中
然而,在wdio.ci.conf.ts文件中,我将其设置为
services:[ ['chromedriver',{
chromeDriverCustomPath:"src\main\cucumber-webdriver-io\node_modules\webdriver-manager\selenium\chromedriver.exe"
}]],
在这个位置,我希望它选择一个旧版本的铬驱动器,95.0.4638.69
我需要它来运行一个旧版本,因为詹金斯公司的环境已经升级了Chrome。在詹金斯,我得到了错误:
警告网络驱动程序:由于未创建会话,请求失败,状态为500:此版本的ChromeDriver仅支持Chrome 97版本[信息][0-0]当前浏览器版本为95.0.4638.69,二进制路径为/usr/bin/google chrome
感谢您的帮助
wdio.ci.conf.ts(为了更简短,删除了评论(
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/'
});
},
}
软件包.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"
}
}
拼写错误的
chromeDriverCustomPath>gt;chromedriverCustomPath