TA的每日心情 | 郁闷 2017-3-1 13:43 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
你的结构听上去有点迷糊
我是分为3个文件
page 放页面 spec放测试流程。
step里面放具体步骤。要调用步骤
只用改 spec就完了
step
'use strict';
const step = function () {
const page = require('./login.page.js');
const EC = protractor.ExpectedConditions;
this.go = () => {
browser.get('/');
browser.wait(EC.visibilityOf(page.loginButton), 5000, '登陆按钮没有显示')
.then((result) => {
expect(result).toBe(true) })
}
this.login = () => {
let user = constants.USERS.test;
base.login(user);
};
this.logout = () => {
browser.get('/');
base.clickRead(page.menu,'个人设置菜单不可见');
base.clickRead(page.logoutButton,'登出按钮不可见');
browser.wait(EC.visibilityOf(page.loginButton), 5000, '登录按钮不可见')
.then((result) => { expect(result).toBe(true) })
}
}
module.exports = new step();
page
'use strict';
module.exports = {
loginPage: element.all(by.css('[ui-view=content] p')),
nameInput: element(by.id('username')),
passwordInput: element(by.id('password')),
loginButton: element(by.id('login-btn01')),
menu: element(by.id('account-menu')),
logoutButton: element(by.id('logout')),
accountname: element(by.css('span.hidden-sm.ng-binding'))
}
spec
'use strict';
const step = require('./login.step.js');
describe('login page', function () {
it('should navigate to the login page', function () {
step.go();
});
it('should navigate to the main page', function () {
step.login();
});
it('should return to the login page', function () {
step.logout();
});
/* */
}); |
|