내가 나를 위해 모든 일을 (아래) 구글 인증 페이지 개체가 있습니다.
여기의 키는 "isAngularSite (false);"입니다. 기능 마녀는 '각진'또는 '비 앵글'웹 사이트에 들어가면 웹 드라이버에게 지시합니다. (아래 구현).
/* global element, browser, by */
'use strict';
var GOOGLE_USERNAME = '[email protected]';
var GOOGLE_PASSWORD = 'password';
var ec = protractor.ExpectedConditions;
var Google = function() {
this.emailInput = element(by.id('Email'));
this.passwordInput = element(by.id('Passwd'));
this.nextButton = element(by.id('next'));
this.signInButton = element(by.id('signIn'));
this.approveAccess = element(by.id('submit_approve_access'));
this.loginToGoogle = function() {
var self = this;
/* Entering non angular site, it instructs webdriver to switch
to synchronous mode. At this point I assume we are on google
login page */
isAngularSite(false);
this.emailInput.sendKeys(GOOGLE_USERNAME);
this.nextButton.click();
this.passwordInput.isPresent().then(function() {
browser.wait(ec.visibilityOf(self.passwordInput), BROWSER_WAIT).then(function() {
self.passwordInput.sendKeys(GOOGLE_PASSWORD);
self.signInButton.click();
browser.wait(ec.elementToBeClickable(self.approveAccess), BROWSER_WAIT).then(function() {
self.approveAccess.click();
/* Now we are being redirected to our app, switch back to
async mode (page with angular) */
isAngularSite(true);
});
});
});
}
}
module.exports = new Google();
--- 즉 당신이 그것을 사용하는 것이 방법 --- protractor.conf.js
onPrepare: function() {
global.isAngularSite = function (flag) {
console.log('Switching to ' + (flag ? 'Asynchronous' : 'Synchronous') + ' mode.')
browser.ignoreSynchronization = !flag;
},
global.BROWSER_WAIT = 5000;
}
에이 던져 :
it('should login though google', function(done) {
mainPage.loginBtn.click().
then(function() {
loginPage.connectWithGoogleBtn.click();
googlePage.loginToGoogle();
browser.wait(mainPage.userName.isPresent()).
then(function() {
expect(mainPage.userName.getText()).
toEqual('[email protected]');
done();
});
});
});
덕분에, 내가 가진 유사한 문제에 도움 – flaky
저는 마지막 리소스로서 각도기 테스트에서 seeps를 사용할 것입니다. – demee
DOM에서 요소가 변경 될 때까지 기다리지 않는 이유는 무엇입니까? – LeeGee