gulp-protractor无法执行测试

时间:2016-02-01 19:11:00

标签: gulp-protractor

我无法使用gulp-protractor任务运行测试。它启动独立的Selenium Server并启动Chrome浏览器,但之后不执行任何操作。

gulp.js

var gulp = require('gulp');
var gp = require('gulp-protractor');
var protractor = require("gulp-protractor").protractor;
var webdriver_standalone = require("gulp-protractor").webdriver_standalone;
gulp.task('protractor',function(cb) {
    gulp.src(['./test/e2e/*.js'])
        .pipe(protractor({
        configFile: 'conf.js'
    })).on('error', function(e) {
        console.log(e)
    }).on('end', cb);
})

conf.js

exports.config = {
//directConnect: true,
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.48.2.jar',
specs: ['./test/e2e/*.js'],
baseUrl: http://url


Console output

[13:25:11] Starting 'protractor'...
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://IP:64422/wd/hub
    Started

.........*

Pending:

1) should be able to click on Company Name "ABC firm
  No reason given

10 specs, 0 failures, 1 pending spec
Finished in 0.041 seconds
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chromeANY #1 passed
[13:25:17] Finished 'protractor' after 5.69 s

请建议。

1 个答案:

答案 0 :(得分:2)

在gulpfile.js

var angularProtractor = require('gulp-angular-protractor');

gulp.task('test', function (callback) {

     gulp
         .src([__dirname+'/public/apps/adminapp/**/test/**_test.js'])
         .pipe(angularProtractor({
             'configFile': 'public/apps/adminapp/app.test.config.js',
             'debug': false,
             'args': ['--suite', 'adminapp'],
             'autoStartStopServer': true
         }))
         .on('error', function(e) {
             console.log(e);
         })
        .on('end',callback);
});

在配置文件

exports.config = {
  baseUrl: 'http://localhost:8000/#/login',
  framework:'jasmine',
  seleniumServerJar : '../../../node_modules/selenium-standalone-jar/bin/selenium-server-standalone-2.45.0.jar',
  suites: {
    adminapp: [
       'login/test/login_test.js',
        'jobs/test/jobs-edit_test.js'
      ]
  },

  capabilities: {
    browserName: 'chrome'
  }
}

它非常简单直接,也适合我。