Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 等待量角器与页面同步时出错:“0”;window.angular未定义_Angularjs_Jasmine_Protractor - Fatal编程技术网

Angularjs 等待量角器与页面同步时出错:“0”;window.angular未定义

Angularjs 等待量角器与页面同步时出错:“0”;window.angular未定义,angularjs,jasmine,protractor,Angularjs,Jasmine,Protractor,我刚开始使用量角器。我创建了几个页面对象,到目前为止一切都很好。我登录到一个页面,并被重定向到myaccount页面 在那一页上,我得到了以下错误: 等待量角器与页面同步时出错:“window.angular未定义 我的代码在这里: var myaccount = function(){ //some function but everything is commented out }; module.exports = new myaccount(); 下面是我的登录测试: thi

我刚开始使用量角器。我创建了几个页面对象,到目前为止一切都很好。我登录到一个页面,并被重定向到myaccount页面

在那一页上,我得到了以下错误: 等待量角器与页面同步时出错:“window.angular未定义

我的代码在这里:

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页面,但量角器会抛出上述错误


有人能帮我一下吗?

窗口。角度未定义
表示您试图使量角器转到一个非角度的页面

请参见此处mcalthrop的答案:

可以用like

var newpage = new RegExp('welcome', 'i');
submitButton.click();
waitForUrlToChangeTo(newpage).then(function () {
        expect(browser.getTitle()).toEqual('Welcome!');
});

哦,还有一件事。我熟悉java,我可以在测试期间返回一个新的页面对象。(例如:使用页面工厂)我可以在量角器中执行相同的操作吗?或者有必要返回不同的页面对象吗?谢谢!我也遇到了相同的错误。你找到了解决问题的方法吗?如果是,请发布答案并接受它?
/**
 * @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);
                });
            });
        }
    );
}