Browser.wait不会在给定的毫秒内等待

问题描述 投票:0回答:1

[因此,我在使用browser时遇到问题。请等待使用量角器,摩卡和chai。基本上,我创建的一个简单脚本基本上是:

var EC = protractor.ExpectedConditions;
describe('Personal information', function () {
    var EC = protractor.ExpectedConditions;

    this.timeout(5000);

    it('test', function (done) {

        browser.driver
            .then(() => browser.wait(EC.presenceOf(element(by.xpath("//root"), 1000, "timed out TEST")
            .then(() => done());
    });

如您所见,我添加了一个函数this.timeout(5000);,这意味着5秒钟后它将引发错误,但是我已进入浏览器。等待1000毫秒后超时,这意味着1秒钟后应引发时间错误1秒后退出。

但是似乎它没有执行此操作,而是等待5秒钟并抛出Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.,我对自己在这里做错的事情感到非常困惑。所以我在这里!

如何使它等待我所给的金额?

致GUY:

describe('Personal information', function () {
    var EC = protractor.ExpectedConditions;

    this.timeout(0);

    browser.wait(EC.presenceOf(element(by.xpath("//root"))), 1000, "timed out TEST");
    it("test"........
selenium protractor mocha chai
1个回答
0
投票

我不确定this.timeout()的工作原理,但我怀疑它的行为类似于隐式等待。 element(by.xpath("//root"))尝试在定义的5秒钟内定位元素,只有在该失败之后browser.wait才检查是否达到了1秒超时。

您可以在使用this.timeout(0);之前设置browser.wait

© www.soinside.com 2019 - 2024. All rights reserved.