量角器在I / launcher上无限期挂起 - 运行1个WebDriver实例

时间:2016-11-08 18:47:54

标签: angularjs google-chrome selenium-webdriver protractor

我无法让Protractor在OS X El Capitan上使用Chrome运行我的测试。运行以下命令:

webdriver-manager start在一个终端

另一个

protractor tests/e2e/protractor.conf.js --suite=invite

当我运行第二个命令时,我得到的只是[13:46:24] I/launcher - Running 1 instances of WebDriver,然后它就会挂起。

这是我的代码。

测试/ E2E / protractor.conf.js

"use strict";

const suites = {
  invite: [
    'invite/invite.js'
  ],
  'invite:full': [
    'invite/**/*.js',
    '!invite/**/*_page_model.js'
  ],
  greeting: [
    'greeting/greeting.js'
  ],
  'greeting:full': [
    'greeting/**/*.js',
    '!greeting/**/*_page_model.js'
  ]
};

const chromeOptions = {
  args: [
    '--disable-extensions'
  ]
};

const browsers = [{
  browserName: 'chrome',
  chromeOptions: chromeOptions
}];

exports.config = {
  seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
  framework: 'jasmine',

  specs: [
    'invite/invite.js',
    'greeting/greeting.js'
  ],

  allScriptsTimeout: 360000,
  getPageTimeout: 12500,
  rootElement: 'body',
  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    isVerbose: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 400000
  },

  skipSourceMapSupport: false,
  directConnect: false,

  suites: suites,

  // chromeDriver: require('chromedriver').path,
  multiCapabilities: browsers,
  disableEnvironmentOverrides: true,
  onPrepare: function () {
    browser.ignoreSynchronization = false;
    let SpecReporter = require('jasmine-spec-reporter');

    // add jasmine spec reporter
    jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
  }
};

invite.js

"use strict";

const EC = protractor.ExpectedConditions;
const InvitePage = require('./invite_page_model.js');
const data = require('../data.js');

describe('Invite Test:', function(){
  beforeEach(function (){
    InvitePage.setWidth();

    browser.get(data.getUrl('ivt'));
    return browser.wait(EC.presenceOf(element(by.name('event_name'))), 15000);
  });

  it('should throw an error when there\'s profanity in the event name', function(){
    var details = InvitePage.Details();
    element(by.name('event_name')).clear();
    element(by.name('event_name')).clear();
    element(by.name('event_name')).sendKeys('some fucking event name');
    element(by.buttonText('NEXT')).click();
    browser.waitForAngular();
    expect(element.all(by.css('.input-error')).count()).toBe(1);

  });
});

invite_page_model.js

"use strict";

const _ = require('lodash');

const data = require('../data.js');
const PageModel = require('../pagemodel.js');

/**
 * Gets mock data for details step
 */
let Details = function(eventName, firstName, date) {
    eventName == undefined ? element(by.name('event_name')).sendKeys("some event name") : element(by.name('event_name')).sendKeys(eventName);
    firstName == undefined ? element(by.name('hostname')).sendKeys(data.getFirstName()) : element(by.name('hostname')).sendKeys(firstName); 
    date == undefined ? element(by.name('date')).sendKeys(PageModel.getDate()) : element(by.name('date')).sendKeys(date);
    element(by.name('start_time')).sendKeys("1:00 PM");
    element(by.name('end_time')).sendKeys("3:00 PM");
};

/**
 * Mock data for address step
 */ 
let Address = function(address1, address2, city, zip) {
    address1 == undefined ? element(by.name('address')).sendKeys(data.getAddressLine()) : element(by.name('address')).sendKeys(address1);   
    address2 == undefined ? element(by.name('address2')).sendKeys(data.getAddressLine2()) : element(by.name('address2')).sendKeys(address2);
    city == undefined ? element(by.name('city')).sendKeys(data.getCity()) : element(by.name('city')).sendKeys(city);
    zip == undefined ? element(by.name('zip')).sendKeys(data.getZip()) : element(by.name('zip')).sendKeys(zip);
};

/**
 * Mock data for message step
 */
let Message = function(message){
    message == undefined ? element(by.name('message')).sendKeys(data.getMessage()) : element(by.name('message')).sendKeys(message);
};

module.exports = _.assignIn(PageModel, {
    Details: Details,
    Address: Address,
    Message: Message
});

1 个答案:

答案 0 :(得分:0)

suites: suitesexports.config的值替换为下面的确切数组值,

suites : {
           invite: [
             'invite/invite.js'
           ],
           'invite:full': [
              'invite/**/*.js',
              '!invite/**/*_page_model.js'
           ],
           greeting: [
              'greeting/greeting.js'
           ],
           'greeting:full': [
                'greeting/**/*.js',
                '!greeting/**/*_page_model.js'
           ]
     }

在命令行中,您可以将套件名称传递为protractor tests/e2e/protractor.conf.js --suite invite