1

I am struggling with fixing time out issue in protractor with below code.

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);
        };

Gone through few links like below. Unfortunately nothing worked for me.

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)
Community
  • 1
  • 1
Shabar
  • 2,617
  • 11
  • 57
  • 98
  • can you try, instead of the EC approach: `browser.wait(function(){ return element(by.id('support-dashboard-btn')).isPresent(); },3000);` – Vlad Vidac Sep 28 '16 at 08:43

1 Answers1

1

Thats a valid error saying that Protarctor timed out waiting for the specific period(3000ms) in the below browser.waitfor element dashboardPage.supportButton

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

May be you have to increase the timeout or check if the element definition is correct

Also another advice, you neednt use browser.waitForAngular() , Protractor automatically does that for you

AdityaReddy
  • 3,625
  • 12
  • 25
  • I have tried by increasing timeout which didn't help. I have set default jasmine timeout to `defaultTimeoutInterval: 2500000 `. The reason why I have put `browser.waitForAngular(); ` because there is no url there to know angular it's a new page. – Shabar Sep 25 '16 at 09:18
  • The timeout in your case is not the Jasmine timeout but the wait timeout.Can you try something like this `browser.wait(EC.visibilityOf(dashboardPage.supportButton), 10000)` – AdityaReddy Sep 25 '16 at 09:31
  • I tried `browser.wait(EC.visibilityOf(dashboardPage.supportButton), 25000) ` still the same result. – Shabar Sep 25 '16 at 09:47
  • oh .. The error is valid one and may be you have to re-visit how you are identifying(locator strategy) `dashboardPage.supportButton` and if it is populating on the page after `loginClick()` – AdityaReddy Sep 25 '16 at 10:09
  • Updated the question with additional details for more clarity. After clicking login button I can see the dashboard page and support button. – Shabar Sep 25 '16 at 10:25
  • Is your website in public domain? May be taking a loot at ur app will help – AdityaReddy Sep 26 '16 at 05:25