1
我想測試我的註冊模態是否存在點擊註冊按鈕時,我的問題是,它似乎是量角器在角度打開模式和測試失敗之前完成測試,我的另一個解決方案是使用預期條件,但由於某些原因,這不起作用,等待功能不會等待我設置的時間,測試正常運行並失敗。角度量角器測試存在的模態
var SignUpPage = require('./signup.page');
describe('signup page', function() {
var SignupPage;
beforeEach(function() {
browser.get('http://localhost:9000');
browser.waitForAngular();
SignupPage = new SignUpPage();
});
it('should open the modal when clicking signup in the main nav', function() {
var EC = protractor.ExpectedConditions;
SignupPage.clickModalBtn();
browser.wait(EC.presenceOf(SignupPage.getModalEle()), 10000);
expect(SignupPage.getModalEle().isPresent()).toBe(true);
});
});
的Signuppage:
function SignUpPage() {
this.openModalBtn = element(by.css('.nav-sign-in-btn'));
this.modal = element(by.css('.reSkill-auth'));
this.email = element(by.css('input[type="email"'));
this.password = element(by.css('input[type="password"'));
this.signInBtn = element(by.css('button[type="submit"]'));
}
SignUpPage.prototype.clickModalBtn = function() {
this.openModalBtn.click();
}
SignUpPage.prototype.getModalEle = function() {
return this.modal;
}
SignUpPage.prototype.setEmailAndPassword = function() {
this.email.sendkeys('[email protected]');
this.password.sendkeys('123456789');
}
SignUpPage.prototype.clickSignIn = function() {
this.signInBtn.click();
}
module.exports = SignUpPage;
如何測試呢?
您可以發佈'SignupPage',尤其是'getModalEle'的相關代碼? –
我添加了註冊碼 – Bazinga