我正在尝试使用WebDriver和Protractor运行端到端测试。当我手动运行它时没有问题: webdriver-manager start,然后protractor test-UI/e2e/conf.js
现在,我想要从grunt命令启动它们,所以我尝试使用grunt-shell,并使用“&&”来加入它们。但是在WebDriver等待的时候,测试永远不会开始。以前有人试过这个吗?
谢谢。
发布于 2016-03-12 22:47:15
Grunt-shell有一个分支,称为Grunt-shell-spawn (Github Repo),它允许您异步运行后台进程。在启动selenium webdriver服务器时,这恰好可以很好地帮助自动化量角器测试过程。有一些专门用于启动webdriver服务器的插件,但根据我的经验,它们都有一些小错误,一旦测试完成就会导致错误,或者需要你标记一个标记keepAlive: true,这意味着它不会杀死webdriver服务器进程,迫使你ctrl+c或关闭并重新打开命令提示符,这可能会在开发人员使用功能测试和持续集成(CI)服务器时导致许多问题。正如你在我的“测试”任务结束时所看到的,Grunt shell-spawn能够杀死进程,这对于维护一致性和易用性来说真的是无价的。
'use strict';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-protractor-runner');
var path = require('path');
grunt.initConfig({
...
...
...
shell: {
updateserver: {
options: {
stdout: true
},
command: "node " + path.resolve('node_modules/protractor/bin/webdriver-manager') + ' update --standalone --chrome'
},
startserver: {
options: {
stdout:false,
stdin: false,
stderr: false,
async:true
},
command: 'node ' + path.resolve('node_modules/protractor/bin/webdriver-manager') + ' start --standalone'
},
});
grunt.registerTask('test',[
'shell:updateserver',
'shell:startserver',
'protractor:e2e',
'shell:startserver:kill'
]);发布于 2014-03-20 21:12:42
您可以安装grunt-protractor-runner
npm install grunt-protractor-runner --save-dev有关详细信息,请查看此博客
http://www.codeorbits.com/blog/2014/01/26/angularjs-end-to-end-testing-with-protractor-easy-set-up-with-yeoman/
发布于 2015-07-23 07:51:30
尝试运行grunt --verbose以查看所发生情况的更多详细信息。
https://stackoverflow.com/questions/22327752
复制相似问题