量角器:失败:3056ms后等待超时

时间:2016-09-25 07:58:20

标签: typescript protractor

我正在努力用以下代码解决量角器中的超时问题。

dashboardPage.ts

import { browser, by, element } from 'protractor/globals';

class DashboardPage {

supportButton = element.all(by.id('support-dashboard-btn')).first();


supportClick(): void {
        this.supportButton.click();
    }

}

export = DashboardPage;

supportPage.spe.ts

beforeEach(() => {
        loginPage.getPage();

        loginPage.fillEmail(data.users[0].email);
        loginPage.fillPassword(data.users[0].password);
        loginPage.loginClick();
        browser.waitForAngular();



        browser.wait(EC.visibilityOf(dashboardPage.supportButton), 3000).then(function () {            *** step Failed: Wait timed out after 3056ms
        dashboardPage.supportClick();
    }), function (error) {
    expect(true).toBe(false);
        };

通过以下几个链接消失了。不幸的是没有什么对我有用。

How to have protractor reliable results?

Protractor: wait method isn't work

Error:

     Failed: Wait timed out after 3056ms
      Stack:
        Error: Wait timed out after 3056ms
            at C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2364:22
            at ManagedPromise.invokeCallback_ (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14)
            at TaskQueue.execute_ (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
            at TaskQueue.executeNext_ (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21)
            at asyncRun (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27)
            at C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7
            at process._tickCallback (internal/process/next_tick.js:103:7)
        From: Task: <anonymous wait>
            at ControlFlow.wait (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2352:17)
            at WebDriver.wait (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:712:29)
            at Browser.to.(anonymous function) [as wait] (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\built\browser.js:61:29)
            at Object.<anonymous> tests\Protractor\Support\supportPage.spec.ts:33:17)
            at C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:96:23
            at new ManagedPromise (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1082:7)
            at controlFlowExecute (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:82:18)
            at TaskQueue.execute_ (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
            at TaskQueue.executeNext_ (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21)
            at asyncRun (C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2820:25)
            at C:\Users\My\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7
            at process._tickCallback (internal/process/next_tick.js:103:7)

1 个答案:

答案 0 :(得分:1)

这是一个有效的错误,说明Protarctor超时等待3000ms元素browser.wait下面的特定时期(dashboardPage.supportButton

browser.wait(EC.visibilityOf(dashboardPage.supportButton), 3000)

您可能需要增加超时或检查元素定义是否正确

另外一个建议,你不需要使用browser.waitForAngular(),Protractor会自动为你做这个