webdriver-io - WebdriverIO 在尝试运行测试时出错
问题描述
我在运行我的 WebdriverIO 测试时遇到问题,我认为这与我如何处理在公司代理后面运行有关。过去一切正常,但突然它们停止了,在尝试了几个小时后,我已经没有想法了。
http_proxy
我的代理详细信息以和的名称保存为 Windows 系统变量https_proxy
。我没有改变这些。我用于变量的格式是这样的 - http://myusername:mypassword@myproxyaddress:8080
。
通过外部连接连接到互联网时,我也会遇到错误,所以我不是 100% 是它的代理造成的。
我已经尝试更新我的所有包,所以我的包文件现在看起来像这样:
{
"name": "name",
"version": "1.0.0",
"description": "UI Tests",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/wdio ./wdio.conf.js"
},
"author": "Matt Thomas",
"license": "ISC",
"devDependencies": {
"@wdio/dot-reporter": "^5.18.6",
"@wdio/local-runner": "^5.18.6",
"@wdio/mocha-framework": "^5.18.6",
"@wdio/selenium-standalone-service": "^5.16.10",
"@wdio/spec-reporter": "^5.18.6",
"@wdio/sync": "^5.18.6",
"chai": "^4.2.0",
"chai-webdriverio": "^1.0.0",
"chromedriver": "^79.0.3",
"local-runner": "^0.1.1-alpha",
"wdio-chromedriver-service": "^5.0.2",
"webdriver": "^5.18.6"
},
"dependencies": {
"@wdio/cli": "^5.18.6"
}
}
我的 wdio.conf.js 文件在这里(从实际文件中删除了注释):
exports.config = {
specs: [
'./test/**/*.js'
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
maxInstances: 10,
capabilities: [{
maxInstances: 5,
browserName: 'chrome'
}],
logLevel: 'trace',
bail: 0,
baseUrl: 'https://apps-dev.bhp.com/moc/',
waitforTimeout: 15000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: ['chromedriver','selenium-standalone'],
framework: 'mocha',
reporters: ['spec','dot'],
mochaOpts: {
ui: 'bdd',
timeout: 120000
},
beforeTest: function (test, context) {
const chai = require('chai')
const chaiWebdriver = require('chai-webdriverio').default
chai.use(chaiWebdriver(browser))
global.assert = chai.assert
global.should = chai.should
global.expect = chai.expect
},
}
当我运行测试时我的终端:
PS C:\Test Automation\Projects\WebdriveriO\GlobalMoC> npm test -- --spec ./test/login.test.js
> globalmoc@1.0.0 test C:\Test Automation\Projects\WebdriveriO\GlobalMoC
> wdio ./wdio.conf.js "--spec" "./test/login.test.js"
Execution of 1 spec files started at 2020-02-14T00:54:12.038Z
2020-02-14T00:54:12.042Z DEBUG @wdio/utils:initialiseServices: initialise wdio service "chromedriver"
2020-02-14T00:54:12.131Z DEBUG @wdio/utils:initialiseServices: initialise wdio service "selenium-standalone"
2020-02-14T00:54:12.204Z INFO @wdio/cli:launcher: Run onPrepare hook
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}) on port 4444
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
2020-02-14T00:54:12.793Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Could not download https://selenium-release.storage.googleapis.com/3.14/IEDriverServer_Win32_3.14.0.zip: Error: unable to get local issuer certificate
at Request.<anonymous> (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\selenium-standalone\lib\install.js:387:12)
at Object.onceWrapper (events.js:286:20)
at Request.emit (events.js:198:13)
at Request.EventEmitter.emit (domain.js:448:20)
at Request.onRequestError (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\request\request.js:881:8)
at ClientRequest.emit (events.js:198:13)
at ClientRequest.EventEmitter.emit (domain.js:448:20)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:198:13)
at TLSSocket.EventEmitter.emit (domain.js:448:20)
Continue...
2020-02-14T00:54:12.831Z INFO @wdio/local-runner: Start worker 0-0 with arg: ./wdio.conf.js,--spec,./test/login.test.js
[0-0] 2020-02-14T00:54:14.120Z INFO @wdio/local-runner: Run worker command: run
[0-0] RUNNING in chrome - C:\Test Automation\Projects\WebdriveriO\GlobalMoC\test\login.test.js
[0-0] 2020-02-14T00:54:14.473Z DEBUG @wdio/local-runner:utils: init remote session
[0-0] 2020-02-14T00:54:14.477Z INFO webdriverio: Initiate new session using the webdriver protocol
2020-02-14T00:54:14.481Z INFO webdriver: [POST] http://127.0.0.1:4444/session
2020-02-14T00:54:14.482Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome' } }
[0-0] 2020-02-14T00:54:14.629Z DEBUG webdriver: request failed due to missing body
[0-0] 2020-02-14T00:54:14.630Z WARN webdriver: Request failed due to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>406 - Client browser does not accept the MIME type of the requested page.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
<h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
</fieldset></div>
</div>
</body>
</html>
[0-0] 2020-02-14T00:54:14.630Z INFO webdriver: Retrying 1/3
2020-02-14T00:54:14.630Z INFO webdriver: [POST] http://127.0.0.1:4444/session
2020-02-14T00:54:14.630Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome' } }
2020-02-14T00:54:14.661Z DEBUG webdriver: request failed due to missing body
2020-02-14T00:54:14.661Z INFO webdriver: Retrying 2/3
2020-02-14T00:54:14.661Z INFO webdriver: [POST] http://127.0.0.1:4444/session
2020-02-14T00:54:14.661Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome' } }
[0-0] 2020-02-14T00:54:14.661Z WARN webdriver: Request failed due to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>406 - Client browser does not accept the MIME type of the requested page.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
<h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
</fieldset></div>
</div>
</body>
</html>
2020-02-14T00:54:14.691Z WARN webdriver: Request failed due to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>406 - Client browser does not accept the MIME type of the requested page.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
<h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
</fieldset></div>
</div>
</body>
</html>
2020-02-14T00:54:14.722Z ERROR webdriver: Request failed due to Error: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>406 - Client browser does not accept the MIME type of the requested page.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
<h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
</fieldset></div>
</div>
</body>
</html>
at getErrorFromResponseBody (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\webdriver\build\utils.js:117:12)
at Request._callback (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\webdriver\build\request.js:111:64)
at Request.self.callback (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\request\request.js:185:22)
at Request.emit (events.js:198:13)
at Request.EventEmitter.emit (domain.js:448:20)
at Request.<anonymous> (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\request\request.js:1161:10)
at Request.emit (events.js:198:13)
at Request.EventEmitter.emit (domain.js:448:20)
at IncomingMessage.<anonymous> (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:286:20)
2020-02-14T00:54:14.723Z ERROR webdriver: Error: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>406 - Client browser does not accept the MIME type of the requested page.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
<h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
</fieldset></div>
</div>
</body>
</html>
at getErrorFromResponseBody (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\webdriver\build\utils.js:117:12)
at Request._callback (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\webdriver\build\request.js:111:64)
at Request.self.callback (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\request\request.js:185:22)
at Request.emit (events.js:198:13)
at Request.EventEmitter.emit (domain.js:448:20)
at Request.<anonymous> (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\request\request.js:1161:10)
at Request.emit (events.js:198:13)
at Request.EventEmitter.emit (domain.js:448:20)
at IncomingMessage.<anonymous> (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:286:20)
2020-02-14T00:54:14.724Z ERROR @wdio/runner: Error: Failed to create session.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>406 - Client browser does not accept the MIME type of the requested page.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
<h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
</fieldset></div>
</div>
</body>
</html>
at startWebDriverSession (C:\Test Automation\Projects\WebdriveriO\GlobalMoC\node_modules\webdriver\build\utils.js:45:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
[0-0] Error: Failed to create session.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>406 - Client browser does not accept the MIME type of the requested page.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>406 - Client browser does not accept the MIME type of the requested page.</h2>
<h3>The page you are looking for cannot be opened by your browser because it has a file name extension that your browser does not accept.</h3>
</fieldset></div>
</div>
</body>
</html>
[0-0] 2020-02-14T00:54:14.691Z DEBUG webdriver: request failed due to missing body
2020-02-14T00:54:14.691Z INFO webdriver: Retrying 3/3
2020-02-14T00:54:14.691Z INFO webdriver: [POST] http://127.0.0.1:4444/session
2020-02-14T00:54:14.692Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome' } }
2020-02-14T00:54:14.722Z DEBUG webdriver: request failed due to missing body
2020-02-14T00:54:15.284Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in chrome - C:\Test Automation\Projects\WebdriveriO\GlobalMoC\test\login.test.js
2020-02-14T00:54:15.302Z INFO @wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:03
2020-02-14T00:54:15.306Z INFO @wdio/local-runner: Shutting down spawned worker
2020-02-14T00:54:15.569Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2020-02-14T00:54:15.578Z INFO @wdio/local-runner: shutting down
npm ERR! Test failed. See above for more details.
解决方案
由于您尝试在代理后面使用 selenium 独立服务,因此您应该在配置文件中包含以下设置。这对我有用。我已经包含了一些你可以参考的文件。
skipSeleniumInstall: false,
seleniumInstallArgs: {
requestOpts: {
strictSSL: false,
timeout: 10000,
proxy: proxyurl,
},
},
https://webdriver.io/docs/selenium-standalone-service.html#skipseleniuminstall
WebdriverIO:如何修复错误“未知错误:无法获得自动化扩展”?
干杯!
推荐阅读
- git - Git 帮助:在 Android 中中止 git commit,但更改存在于本地而非远程
- javascript - 反应引导,bsStyle 不工作
- c# - 如何将 ValueTuple 命名功能与匿名方法一起使用?
- android - android上的低音库:如何将音频保存到文件?
- asp.net-mvc-5 - 可以列出类型
包含@Html.ActionLinks 作为模型从控制器传递到视图? - codenameone - 找不到theme.css 文件代号一
- node.js - MEAN堆栈如何将输入密码与保存在数据库中的哈希和盐字符串进行比较
- json - Haskell JSON 解析与 Aeson
- html - 为什么顶部和底部边距在子容器中消失?
- unix - 使用后台进程运行 ssh 脚本