1
我最近尝试使用与量角器页面对象模型下面这篇文章 http://engineering.wingify.com/posts/angularapp-e2e-testing-with-protractor/量角器经过我的测试中,不执行“它”块
然而,当我跑我的测试,我it
块没有得到执行。
下面是我的登录页面对象
/*File Name : loginPage.js*/
var loginPage = function() {
'use strict';
this.email = element(by.id('Email'));
this.next = element(by.id('next'));
this.pwd = element(by.id('Passwd'));
this.signin = element(by.id('signIn'));
this.submitButton = element(by.css('.login-form button[type="submit"]'));
//this.classitem = element(by.css('hap-class-item'));
//this.googlesigninbtn = element(by.css('[ng-click="login_google()"]'));
//******************** functions *******************
this.enterEmail = function (email) {
browser.ignoreSynchronization = true;
//browser.sleep(2000);
this.email.clear();
this.email.sendKeys(email);
this.next.click();
browser.sleep(2000);
};
this.enterPassword = function (pwd) {
browser.ignoreSynchronization = true;
this.pwd.clear();
browser.sleep(2000);
this.pwd.sendKeys(pwd);
this.signin.click();
browser.sleep(2000);
};
};
module.exports = {
log: new loginPage()
};
下面是我的注销页面对象
/*File Name : logoutPage.js*/
var logoutPage = function() {
'use strict';
\t \t this.logoutcaret = element(by.css('[ng-if="api.userNav.items"]'));
\t this.logoutbtn = element(by.css('[ng-click="openModal()"]'));
\t this.googlelogout = element(by.css('[ng-click="logout()"]'));
var EC1 = protractor.ExpectedConditions;
//******************** functions *******************
this.logoutfn = function() {
\t browser.wait(EC1.visibilityOf(this.logoutcaret),15000);
\t this.logoutcaret.click();
\t this.logoutbtn.click();
\t this.googlelogout.click();
};
};
module.exports = {
log: new logoutPage()
};
下面是我的基地页已经登录和退出功能创建的,是用于每次测试
/*File Name : LoginOut.js*/
//var switchwin = require('../commons/selectwindow.js');
var loginPage = require('../objects/loginpage.js'),
eml = 'abc',
password = 'pwd';
exports.login = function() {
//browser.driver.manage().deleteAllCookies();
browser.driver.get('https://accounts.google.com/ServiceLogin');
loginPage.log.enterEmail(eml);
loginPage.log.enterPassword(password);
browser.driver.get('URL');
};
var logoutPage = require('../objects/logoutpage.js');
exports.logout = function() {
logoutPage.log.logoutfn();
};
最后,下面是我的测试,它总是通过,但它只是登录和注销然而,在“它”块不执行任何操作。
/*File Name : tests*/
'use strict';
describe('I want to test Smartshare', function() {
var loginMod = require('../commons/loginout.js');
//login before each test
beforeEach(function() {
loginMod.login();
});
var loginMod = require('../commons/loginout.js');
//logout after each test
afterEach(function() {
loginMod.logout();
});
var smartshareMod = require('../objects/smartsharepage.js');
//copy doc test
it('should test sharing a document', function() {
\t exports.copydoc = function() {
\t \t smartshareMod.log.copyDoc().then(function(){
\t \t \t console.log('document copied');
\t \t });
\t };
});
});
node.js version - v6.4.0
protractor version - 4.0.11
Running on MacOS Sierra
webdriver-manager updated to latest
感谢@alecxe该诀窍。 –