等待量角器与页面同步时出错:“window.angular未定义 [英] Error while waiting for Protractor to sync with the page: "window.angular is undefined
问题描述
我刚刚开始使用Protractor。我创建了几个页面对象,到目前为止一切正常。我登录到一个页面,然后我被重定向到myaccount页面。
I've just started to use Protractor. I created several page objects and everything is working fine till now. I log in to a page and I'm being redirected to the myaccount page.
在该页面上,我收到以下错误:
等待时出错与页面同步的量角器:window.angular未定义。
On that page, I got the following error: Error while waiting for Protractor to sync with the page: "window.angular is undefined.
我的代码在这里:
var myaccount = function(){
//some function but everything is commented out
};
module.exports = new myaccount();
这是我的登录测试:
this.loginSuccess = function(){
userName.sendKeys(params.registration.email);
password.sendKeys(params.registration.password);
submitButton.click();
};
点击后,myaccount页面出现,但量角器抛出上述错误。
After the click, myaccount page appears but the protractor throws the mentioned error.
有人可以帮我吗?
推荐答案
请参阅mcalthrop的答案: https://github.com/angular/protractor/issues/610
See the answer from mcalthrop here: https://github.com/angular/protractor/issues/610
可以使用像
var newpage = new RegExp('welcome', 'i');
submitButton.click();
waitForUrlToChangeTo(newpage).then(function () {
expect(browser.getTitle()).toEqual('Welcome!');
});
/**
* @name waitForUrlToChangeTo
* @description Wait until the URL changes to match a provided regex
* @param {RegExp} urlRegex wait until the URL changes to match this regex
* @returns {!webdriver.promise.Promise} Promise
*/
function waitForUrlToChangeTo(urlRegex) {
var currentUrl;
return browser.getCurrentUrl().then(function storeCurrentUrl(url) {
currentUrl = url;
}
).then(function waitForUrlToChangeTo() {
return browser.wait(function waitForUrlToChangeTo() {
return browser.getCurrentUrl().then(function compareCurrentUrl(url) {
return urlRegex.test(url);
});
});
}
);
}
这篇关于等待量角器与页面同步时出错:“window.angular未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!