我正在使用POM概念和所有指示:
https://npm.runkit.com/protractor-angular-screenshot-reporter
https://github.com/bcole/protractor-angular-screenshot-reporter/blob/master/README.md
但仍未生成任何报告。这是我缺乏的东西吗?早些时候我使用了'protractor-jasmine2-html-reporter',它运行正常。
我使用cmd运行量角器conf.js时得到的控制台输出正确:
4个规格,3个失败
完成时间为32.847秒
[11:32:40]我/本地 - 关闭selenium独立服务器
[11:32:40] I / launcher - WebDriver的0个实例仍在运行
[11:32:40]我/发射器 - 铬#01失败3次测试
[11:32:40]我/发射器 - 整体:3个失败的规格
[11:32:40] E / launcher - 进程已退出,错误代码为1
项目结构: Project Structure
信息页/ AllevaHome.js
var AllevaHomePage = function() {
var logoutBtn = element(by.className('logoutbtn'));
this.isLogoutDisplays = function(){
var flag = logoutBtn.isDisplayed();
return flag
};
this.logout = function(){
logoutBtn.click();
};
};
module.exports = new AllevaHomePage();
信息页/ AllevaLogin.js
var AllevaLoginPage = function() {
var username = element(by.model('LoginViewModel.UserName'));<br>
var password = element(by.model('LoginViewModel.Password'));<br>
var loginBtn = element(by.className('orange-btn login_btn'));<br>
var securityAns = element(by.model('twoFactorModel.answer'));<br>
var proceedBtn = element(by.css('[value="Proceed"]'));<br>
this.get = function() {
browser.get('some url');
browser.manage().window().maximize();
};
function setUsername(user){
username.sendKeys(user);
};
function setPassword(pass){
password.sendKeys(pass);
};
function setAnswer(ans){
securityAns.sendKeys(ans);
};
this.login = function(user, pass, ans){
setUsername(user);
setPassword(pass);
loginBtn.click();
setAnswer(ans);
proceedBtn.click();
};
/* this.getGreetingText = function() {
return greeting.getText();
};*/
};
module.exports = new AllevaLoginPage();
TESTDATA / LoginData.js
'use strict';
module.exports = {
LoginData: {
'Valid Username/Password': {username: 'someuser', password: 'somepass',
answer: 'someans'},
'Invalid Username/Correct Password': {username: 'testuser', password:
'Test@12345', answer: 'kusum'},
'Invalid Username/Invalid Password': {username: 'testuser', password:
'Test@1234', answer: 'kusum'},
'Valid Username/Invalid Password': {username: 'rohitnegi', password:
'Test@1234', answer: 'kusum'}
}
}
测试/ AllevaLoginTest.js
var AllevaLoginObj = require('../pages/AllevaLogin.js');
var AllevaHomeObj = require('../pages/AllevaHome.js');
var LoginData = require('../testdata/LoginData.js');
var using = require('jasmine-data-provider');
describe('Checking Alleva Login Functionality', function() {
using(LoginData.LoginData, function(data, description) {
it('Login with: '+description, function() {
AllevaLoginObj.get();
AllevaLoginObj.login(data.username, data.password, data.answer);
expect(AllevaHomeObj.isLogoutDisplays());
})
});
afterEach(function() {
AllevaHomeObj.logout();
})
});
Conf.js:
var HtmlReporter = require('protractor-angular-screenshot-reporter');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'./tests/AllevaLoginTest.js'
],
capabilities: {
'browserName': 'chrome'
},
onPrepare: function() {
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: '/tmp/screenshots'
}).getJasmine2Reporter());
},
jasmineNodeOpts: {
onComplete: null,
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 2500000
}
};
如果您还有其他需要,请告诉我。