当我运行量角器时,我不断收到没有找到规格的错误。我尝试过一个特定的单个文件,1个目录ProductItem
和一个完整的树e2e/*.js
。
protractor.config.js
e2e/**/*.js
gulpfile.js
exports.config = {
specs: ['e2e/**/*.js'],
capabilities:{
browserName: 'chrome',
debug: true
},
localSeleniumStandaloneOpts:{
port:8082
}
}
E2E / login.specs.js
'use strict';
var gulp = require('gulp');
var protractor = require("gulp-protractor").protractor;
// Setting up the test task
gulp.task('protractor', function(callback) {
gulp
.src(['e2e/**/*.js'])
.pipe(protractor({
configFile: 'protractor.conf.js',
args:['-port','8095']
}))
.on('error', function(e) {
console.log(e);
});
});
我错过了配置吗?
答案 0 :(得分:0)
我发现它,根据AngularJS的e2e测试网站:https://docs.angularjs.org/guide/e2e-testing一切都分为代码块。所以在describe函数中你有beforeEach,afterEach和它。 我把我的'它'在每个'之前的功能。
describe('login to admin app', function(){
beforeEach(function(){
browser.get('http://localhost:3000/#!/login');
});//this line was missing
it('expect to be on the login page', function(){
expect(browser.findElement(by.className('login-page')).isPresent()).toBe(true);
});
it('login to application', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.getCurrentUrl()).toMatch('http://localhost:3000/#!/landing');
});
it('check header after login', function(){
var loginInput = browser.findElement(by.name('username'));
var passwordInput = browser.findElement(by.name('password'));
var submitButton = browser.findElement(by.tagNam('button'));
loginInput.sendKeys('****');
passwordInput.sendKeys('****');
submitButton.click();
expect(browser.findElement(by.id('role')));
expect(browser.findElement(by.id('username')));
var languages = brower.findElement(by.className("language"));
expect(language[0][0].getText().toEqual("NL"));
expect(language[1][0].getText().toEqual("FR"));
});
});