我无法让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
,然后它就会挂起。
这是我的代码。
"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'}));
}
};
"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);
});
});
"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
});
答案 0 :(得分:0)
将suites: suites
内exports.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