【发布时间】:2017-09-06 23:52:11
【问题描述】:
下面是我的 gruntfile.js 。我可以使用 'grunt protractor:run 命令在 UI 上运行量角器测试。
但是,当我尝试运行命令“grunt protractor-xvfb”以便我可以在无头模式下运行测试时,浏览器仍会启动并以与使用 grunt protractor:run 命令相同的方式执行测试。
我期待的是测试在后台运行。
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
protractor: {
options: {
keepAlive: true,
configFile: "../spike-protractor/app/Conf/conf.js",
noColor: false,
args: {
baseUrl: 'https://xxx/xxx/'
}
},
run: {}
},
shell: {
xvfb: {
command: 'Xvfb :99 -ac -screen 0 1600x1200x24',
options: {
async: true
}
}
},
env: {
xvfb: {
DISPLAY: ':99'
}
}
});
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.registerTask('protractor-chrome', ['protractor:chrome']);
grunt.registerTask('protractor-xvfb', [
'shell:xvfb',
'env:xvfb',
'protractor:run',
'shell:xvfb:kill'
]);
}
我尝试从 grunt.registerTask 中注释掉行代码 'protractor:run' 并运行 grunt protractor-xvfb 给我以下输出,根据代码是正确的。这执行得如此之快,就好像什么都没发生一样。我认为我在配置/代码中缺少一些东西来实现无头测试。
运行“shell:xvfb”(shell)任务
运行“env:xvfb”(env) 任务
运行“shell:xvfb:kill”(shell)任务
完成。
我实际上如何继续使用 xvfb + grunt+ protractor 进行无头测试?
【问题讨论】:
标签: gruntjs protractor xvfb headless-browser