在等待 Protractor 与基本量角器测试的页面同步时遇到错误 [英] Running into Error while waiting for Protractor to sync with the page with basic protractor test

查看:19
本文介绍了在等待 Protractor 与基本量角器测试的页面同步时遇到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

describe('my homepage', function() {
    var ptor = protractor.getInstance();
    beforeEach(function(){
        // ptor.ignoreSynchronization = true;
        ptor.get('http://localhost/myApp/home.html');
        // ptor.sleep(5000);
    })
    describe('login', function(){

        var email = element.all(protractor.By.id('email'))
            , pass = ptor.findElement(protractor.By.id('password'))
            , loginBtn = ptor.findElement(protractor.By.css('#login button'))
            ;

        it('should input and login', function(){
            // email.then(function(obj){
            //  console.log('email', obj)
            // })
            email.sendKeys('josephine@hotmail.com');
            pass.sendKeys('shakalakabam');
            loginBtn.click();

        })
    })

});

以上代码返回

 Error: Error while waiting for Protractor to sync with the page: {}

我不知道这是为什么,ptor 正确加载页面,似乎是元素选择失败.

and I have no idea why this is, ptor load the page correctly, it seem to be the selection of the elements that fails.

到 SSHMSH:

谢谢,你几乎是对的,并且给了我正确的理念,所以关键是 ptor.sleep(3000) 让每个页面等待直到 ptor 与项目同步.

Thanks, your almost right, and gave me the right philosophy, so the key is to ptor.sleep(3000) to have each page wait til ptor is in sync with the project.

推荐答案

我得到了同样的错误信息(Angular 1.2.13).我的测试开始得太早了,而且 Protractor 似乎没有等待 Angular 加载.

I got the same error message (Angular 1.2.13). My tests were kicked off too early and Protractor didn't seem to wait for Angular to load.

看来我错误地配置了量角器配置文件.当 ng-app 指令未在 BODY 元素上定义,但在后代上时,您必须将量角器配置文件中的 rootElement 属性调整为选择器定义你的角度根元素,例如:

It appeared that I had misconfigured the protractor config file. When the ng-app directive is not defined on the BODY-element, but on a descendant, you have to adjust the rootElement property in your protractor config file to the selector that defines your angular root element, for example:

// protractor-conf.js
rootElement: '.my-app',

当你的 HTML 是:

when your HTML is:

<div ng-app="myApp" class="my-app">

这篇关于在等待 Protractor 与基本量角器测试的页面同步时遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆