【问题标题】:Grunt stops after running one task with protractor webdriver-manager使用量角器 webdriver-manager 运行一项任务后,Grunt 停止
【发布时间】:2015-11-11 22:53:29
【问题描述】:

我目前正在尝试将一些 Protractor E2E 测试与 grunt 联系起来。到目前为止,还没有那么成功。我能找到的所有文件都说 grunt 应该适合我的情况。但是,在运行webdriver-manager update --standalone 之后,grunt 会退出而不会出现错误消息或运行任何其他任务。

我的 Gruntfile:

'use strict';

module.exports = function(grunt) {

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),
    protractor: {
      options: {
        configFile: "./conf.js", // Default config file 
        keepAlive: true, // If false, the grunt process stops when the test fails. 
        noColor: false, // If true, protractor will not use colors in its output. 
        args: {
          // Arguments passed to the command 
        }
      },
      all: {}   // Grunt requires at least one target to run so you can simply put 'all: {}' here too. 
    },

    protractor_webdriver: {

    update : {
        options: {
          path:'node_modules/.bin/',
          command: ['webdriver-manager update --standalone']
        },
      },
      e2eStart: {
        options: {
          keepAlive: true,
          path:'node_modules/.bin/',
          command: ['webdriver-manager start']
        },
      },
    }
  });

  grunt.registerTask('default', ['protractor_webdriver:update', 'protractor_webdriver:e2eStart', 'protractor:all']);
  grunt.loadNpmTasks('grunt-protractor-webdriver');
  grunt.loadNpmTasks('grunt-protractor-runner');


};

因为可能有人好奇:packages.json

{
  "name": "Protractor-me",
  "description": "Protractor-me!",
  "version": "0.0.1",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-protractor-runner": "~2.0.0",
    "grunt-protractor-webdriver": "~0.2.0",
    "jasmine-reporters": "^2.0.7"
  },
  "install": {}
}

最后,grunt --verbose 输出

$ grunt --verbose
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK

Registering "grunt-protractor-webdriver" local Npm module tasks.
Reading /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-webdriver/package.json...OK
Parsing /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-webdriver/package.json...OK
Loading "protractor_webdriver.js" tasks...OK
+ protractor_webdriver

Registering "grunt-protractor-runner" local Npm module tasks.
Reading /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-runner/package.json...OK
Parsing /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-runner/package.json...OK
Loading "protractor_runner.js" tasks...OK
+ protractor
Loading "Gruntfile.js" tasks...OK
+ default

No tasks specified, running default tasks.
Running tasks: default

Running "default" task

Running "protractor_webdriver:update" (protractor_webdriver) task
Verifying property protractor_webdriver.update exists in config...OK
File: [no files]
Options: path="node_modules/.bin/", command=["webdriver-manager update --standalone"], keepAlive=false
Starting Selenium server
>> selenium standalone is up to date.

>> chromedriver is up to date.

$

它运行 webdriver-manager 更新,然后停止。我的理解是每个任务都应该按顺序运行,并且在它结束或出错之前不会停止。我没有主意了!

【问题讨论】:

    标签: node.js selenium gruntjs npm protractor


    【解决方案1】:

    您可以尝试创建一个调用多个任务的自定义任务,如下所示:

    grunt.registerTask('foo', 'My "foo" task.', function() {
    // Enqueue "bar" and "baz" tasks, to run after "foo" finishes, in-order.
    grunt.task.run('bar', 'baz');
    // Or:
    grunt.task.run(['bar', 'baz']);
    });
    

    http://gruntjs.com/creating-tasks#custom-tasks

    【讨论】:

      猜你喜欢
      • 2016-07-04
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2019-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多