我的团队最近从手动启动webdriver-manager切换到在conf.js文件中指定selenium服务器,如下所示:https://github.com/angular/protractor/blob/master/docs/server-setup.md#standalone-selenium-server。我正在尝试使用以下conf.js运行Protractor,它接受一些参数,然后返回一个配置对象:
//create-conf.js
'use strict';
const path = require('path');
const globalData = require('./globalData');
module.exports = (confLocation, specs, reportDirName, browserName = 'chrome') => {
// We want the reports to be saved relative to the config, so we need to take
// the confLocation as an argument
const reportDestination = path.join(confLocation, '../reports', reportDirName);
return {
'framework': 'jasmine',
'seleniumServerJar': '../../../node_modules/selenium-server-standalone/index.jar',
'chromeDriver': '../../../node_modules/chromedriver/bin/chromedriver',
'seleniumPort': '4444',
'specs': specs,
'restartBrowserBetweenTests': false,
'capabilities': {
browserName: browserName,
chromeOptions: {
args: ['--no-sandbox', '--window-size=800,800'],
prefs: {
downloads: {
prompt_for_download: false,
directory_upgrade: true,
},
},
},
},
'params': globalData.browserParams,
'onPrepare': function() {
let Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: reportDestination,
takeScreenshots: false,
filePrefix: 'htmlReport',
})
);
let JasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(
new JasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: reportDestination,
filePrefix: 'xmlReport',
})
);
},
'jasmineNodeOpts': {
showColors: true,
defaultTimeoutInterval: 200000,
},
};
};
不幸的是,量角器仅提供少量输出然后无限期挂起:
$ protractor configs/reg-conf.js
[18:22:30] I/launcher - Running 1 instances of WebDriver
[18:22:30] I/local - Starting selenium standalone server...
[18:22:31] I/local - Selenium standalone server started at http://10.24.104.84:4444/wd/hub
相同的配置适用于其他同事机器,所以我想知道是否存在某种配置问题。我在Windows 7上,它已经在另一台Windows 7机器和几台Mac上工作。因此,我确信问题出现在某种设置中,而不是在create-conf.js或reg-conf.js文件中。
Chromedriver版本:
$ ./chromedriver.exe -v
ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f)
量角器版本:
$ protractor --version
Version 5.1.2
此外,如果我将配置文件转换回之前的状态,并手动运行webdriver-manager,则量角器可以正常运行。
提前致谢!