有以下protractor.conf.js:
exports.config = {
framework: 'jasmine',
specs: ['e2e-tests/**/*.js'],
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar'
}
Gulp 任务:
gulp.task('e2e-testing', ['webdriver_standalone'], function() {
gulp.src([]).pipe(protractor({ configFile: "protractor.conf.js" }))
.on('error', function(e) { throw e })
});
此代码运行良好,但我必须在开始 e2e
任务之前执行 webdriver-manager start --standalone
。我怎么能省略它?我怎样才能自动做到这一点?提前致谢
最佳答案
只需删除 seleniumAddress
配置选项,以便在您启动测试套件时让 Protractor 自行实例化一个新服务器。否则,如果指定了服务器地址,Protractor 会尝试连接到它而不是创建一个新地址。查看从测试脚本启动服务器部分in the docs :
Please note that if you set seleniumAddress, the settings for seleniumServerJar, seleniumPort, seleniumArgs, sauceUser and sauceKey will be ignored.
关于selenium - 在 Gulp 中自动运行 webdriver 进行端到端测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32953141/