我尝试通过 webdriver-manager 和量角器开始测试。
验证版本:Google Chrome 73.0.3683.86 ChromeDriver 73.0.3683.68
启动 webdriver-managerwebdriver-manager start
并启动量角器
我得到了量角器的错误
enviroment: test
[12:20:23] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[12:20:23] E/driverProvider - Error code: 135
[12:20:23] E/driverProvider - Error message: unknown error: Chrome failed to start: exited abnormally
[12:20:23] E/driverProvider - Error: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.9.0-8-amd64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 172 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'dev', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.0-8-amd64', java.version: '1.8.0_212'
Driver info: driver.version: unknown
at Hosted.<anonymous> (/usr/lib/node_modules/protractor/built/driverProviders/driverProvider.js:69:23)
at Generator.throw (<anonymous>)
at rejected (/usr/lib/node_modules/protractor/built/driverProviders/driverProvider.js:5:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
[12:20:23] E/launcher - Process exited with error code 135
和 webdriver-manager 提供的信息
12:19:38.934 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"count": 1
}
12:19:38.947 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72) on port 15966
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
protractor.conf.js 在项目文件夹中(我在其中执行命令protractor --host https://MySite
let test_url = '';
let enviroment = process.env.NODE_ENV;
console.log('enviroment:', enviroment);
//console.log('process.env:', process.env);
let settings = {
seleniumAddress: 'http://localhost:4444/wd/hub',
//directConnect: true,
specs: ['./e2e/todo-spec.js'],
// Options to be passed to Jasmine-node.
params: {
host: 'http://localhost:3000'
},
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
// The require statement must be down here, since jasmine-reporters@1.0
// needs jasmine to be in the global and protractor does not guarantee
// this until inside the onPrepare function.
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter('xmloutput', true, true)
);
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
}
if(process.env.hasOwnProperty('npm_config_host') && process.env.npm_config_host){
settings.params.host = process.env.npm_config_host
}
exports.config = settings;