简体   繁体   English

browser.wait忽略我的参数以等待20秒

[英]browser.wait ignores my parameter to wait 20 seconds Protractor

I have written this test, however browser doesn't wait those 20 seconds before looking for an element. 我已经编写了此测试,但是浏览器在寻找元素之前不会等待那20秒。 It ignores that part and only wait those default 11 seconds. 它忽略该部分,仅等待那些默认的11秒。 Is there something wrong with my code? 我的代码有问题吗?

it('should navigate to Home tab', function() {
    element(by.css('[ui-sref="main.home"]')).click();

    var telematicsSection = element(by.id('teleMap'));

    var EC = protractor.ExpectedConditions;
    browser.wait(EC.presenceOf(telematicsSection), 20000);
});

This is an error I get 这是我得到的错误

Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. 失败:11秒后超时,等待异步Angular任务完成。 This may be because the current page is not an Angular application. 这可能是因为当前页面不是Angular应用程序。 Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular While waiting for element with locator - Locator: By(css selector, *[id="teleMap"]). 有关更多详细信息,请参阅FAQ: https : //github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular在等待带有定位符的元素时-定位符:By(css选择器,* [id =“ teleMap”])。

@edit @编辑

I've managed to fix it. 我已经设法解决了。 Yash Jagdale's code and Yash Jagdale的代码和

allScriptsTimeout: 20000 allScripts超时:20000

in conf.js made it work. 在conf.js中使其工作。

You can use below way to handle async cycle properly 您可以使用以下方式正确处理异步周期

    it('should navigate to Home tab', function(callback) {
        element(by.css('[ui-sref="main.home"]')).click().then(function() {

        var telematicsSection = element(by.id('teleMap'));

        var EC = protractor.ExpectedConditions;
        browser.wait(EC.presenceOf(telematicsSection), 20000).then(function() {
           callback();
         });
      });
    }, 40000);

Add browser.ignoreSynchronization = true; 添加browser.ignoreSynchronization = true; in onPrepare of protractor conf.js onPrepare量角器conf.js的

onPrepare: function() {

  browser.ignoreSynchronization = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM