在使用selenium独立服务和chrome运行wdio.conf.js时,错误地获取selenium页面的html输出



当使用命令wdio-wdio.conf.js 从wdio运行测试时,我收到错误,后面跟着selenium页面的html代码

package.json看起来像这个

{
"name": "OpenWeathermap",
"version": "1.0.0",
"description": "Tests for Open WeatherMap application",
"main": "index.js",
"scripts": {
"test": "test"
},
"author": "Parth Vyas",
"license": "MIT",
"devDependencies": {
"selenium-standalone": "6.15.1",
"wdio-selenium-standalone-service": "~0.1",
"selenium-webdriver": "^4.0.0-alpha.1",
"wdio-chromedriver-service": "~0.1",
"wdio-cucumber-framework": "^2.2.8",
"wdio-docker-service": "^1.5.0"
},
"dependencies": {
"chromedriver": "^2.43.3",
"allure-commandline": "^2.5.0",
"wdio-allure-reporter": "^0.6.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1"
}
}

wdio.conf.js看起来像这个

exports.config = {
specs: [
'./tests/features/**/*.feature'
],
exclude: [
// 'path/to/excluded/files'
],
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 2,
//
browserName: 'chrome',
chromeOptions: {
//args: ['--headless'],
proxyType: 'MANUAL',
httpProxy: 'http://localhost:4444/console'
}
}],
path:'/',
sync: true,
logLevel: 'verbose',
coloredLogs: true,
deprecationWarnings: true,
bail: 0,
baseUrl: 'https://openweathermap.org',
services: ['selenium-standalone'],
seleniumArgs: {
seleniumArgs: ["-port", "4444"],
javaArgs: [
"-Xmx1024m"
]
},
dockerLogs: './logs',
dockerOptions: {
image: 'selenium/standalone-chrome',
healthCheck: 'http://localhost:4444',
options: {
p: ['4444:4444'],
shmSize: '2g'
}
},
framework: 'cucumber',
cucumberOpts: {
require: ['./tests/features/step-definitions'],        // <string[]> (file/dir) require files before executing features
backtrace: false,   // <boolean> show full backtrace for errors
compiler: [],       // <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
dryRun: false,      // <boolean> invoke formatters without executing steps
failFast: false,    // <boolean> abort the run on first failure
format: ['pretty'], // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
colors: true,       // <boolean> disable colors in formatter output
snippets: true,     // <boolean> hide step definition snippets for pending steps
source: true,       // <boolean> hide source uris
profile: [],        // <string[]> (name) specify the profile to use
strict: false,      // <boolean> fail if there are any undefined or pending steps
tags: [],           // <string[]> (expression) only execute the features or scenarios with tags matching the expression
timeout: 20000,     // <number> timeout for step definitions
ignoreUndefinedDefinitions: false, // <boolean> Enable this config to treat undefined definitions as warnings.
},

控制台上的输出:C: \Users\user\IdeaProjects\OpenWeathermap>wdio wdio.conf.js

[01:10:17]  COMMAND     POST     "/session"
[01:10:17]  DATA                {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"maxInstances":2,"browserName":"c
hrome","chromeOptions":{"proxyType":"MANUAL","httpProxy":"http://localhost:4444/console"},"loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io
","version":"4.14.0","name":"webdriverio"}}}
ERROR: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/assets/displayhelpservlet.css" media="all"/>
<link href="/assets/favicon.ico" rel="icon" type="image/x-icon" />
<script src="/assets/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="/assets/displayhelpservlet.js" type="text/javascript"></script>
<script type="text/javascript">
var json = Object.freeze('{"consoleLink": "u002fwdu002fhub","type": "Standalone","class": "org.openqa.grid.web.servlet.DisplayHelpHandler$DisplayHelpServletConfig","version": "
3.141.0"}');
</script>
</head>
<body>
<div id="content">
<div id="help-heading">
<h1><span id="logo"></span></h1>
<h2>Selenium <span class="se-type"></span>&nbsp;v.<span class="se-version"></span></h2>
</div>
<div id="content-body">
<p>
Whoops! The URL specified routes to this help page.
</p>
<p>
For more information about Selenium <span class="se-type"></span> please see the
<a class="se-docs">docs</a> and/or visit the <a class="se-wiki">wiki</a>.
<span id="console-item">
Or perhaps you are looking for the Selenium <span class="se-type"></span> <a class="se-console">console</a>.
</span>
</p>
<p>
Happy Testing!
</p>
</div>
<div>
<footer id="help-footer">
Selenium is made possible through the efforts of our open source community, contributions from
these <a href="https://github.com/SeleniumHQ/selenium/blob/master/AUTHORS">people</a>, and our
<a href="http://www.seleniumhq.org/sponsors/">sponsors</a>.
</footer>
</div>
</div>
</body>
</html>
chrome
at new RuntimeError (C:UsersuserAppDataRoamingnpmnode_moduleswebdriveriobuildlibutilsErrorHandler.js:143:12)
at Request._callback (C:UsersuserAppDataRoamingnpmnode_moduleswebdriveriobuildlibutilsRequestHandler.js:300:39)
at Request.self.callback (C:UsersuserAppDataRoamingnpmnode_moduleswebdriverionode_modulesrequestrequest.js:185:22)
at Request.emit (events.js:182:13)
at Request.EventEmitter.emit (domain.js:442:20)
at Request.<anonymous> (C:UsersuserAppDataRoamingnpmnode_moduleswebdriverionode_modulesrequestrequest.js:1161:10)
at Request.emit (events.js:182:13)
at Request.EventEmitter.emit (domain.js:442:20)
at IncomingMessage.<anonymous> (C:UsersuserAppDataRoamingnpmnode_moduleswebdriverionode_modulesrequestrequest.js:1083:12)
at Object.onceWrapper (events.js:273:13)
at IncomingMessage.emit (events.js:187:15)
at IncomingMessage.EventEmitter.emit (domain.js:442:20)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

wdio.conf.js中的路径设置为路径:/wd/hub

最新更新