0

I am working on angular 4 test automation and using Protractor tool. After many video tutorials I concluded that there is no need of WAIT functions for synchronization while using protractor. When I use browser.WaitForAngularEnabled(true) it hangs the browser until jasmine default time expires and the test case fails. Attached is the spec.ts beforAll() block code. Can any one tell me whether my concept is false or true and if it is true then what is the issue?

login = new LoginPage();
        addMemeber = new AddMemberClass();

        return new Promise((resolve)=>{
            login.navigateTo().then(()=>{
                login.getEmailInput().sendKeys('valid_email@gmail.com');
                login.getPasswordInput().sendKeys('123456');
                login.getLoginButton().click();
                console.log('here is protractor');                
              
                    browser.waitForAngularEnabled(true);
                    expect(browser.getCurrentUrl()).toContain('organization').then(()=>{
                        console.log('Nave bar present');
                        resolve();
                    })
              

            });
Analyst
  • 751
  • 6
  • 15

1 Answers1

0

Your point is valid for not using Wait functions for synchronization in protractor. Looking at your code looks like you are moving from non-angular to angular application. In this case "waitForAngularEnabled(true)" the Protractor checks for angular variable when loading a new page,

the Default Timeout is for 10 seconds

and if it is not found then throws an error like this:

Message:
_[31m    Failed: script timeout: result was not received in 11 seconds

To solve this at individual level add page timeout parameter in your browser.get(address, timeout_in_millis) and globally add below line in configuration file

getPageTimeout: timeout_in_millis

To get more understanding of waitForAngularEnabled(true) refer this discussion: https://stackoverflow.com/a/44073142/1976848

For timeouts in Protractor: Protractor Timeouts

let me know if this helps!!

Himanil Gupta
  • 91
  • 1
  • 12
  • Thanks. The angular variable wasn't found when i manually inspected the page. Thanks once again – Analyst Dec 06 '19 at 05:32
  • Also the link mentioned cleared my concepts a bit more – Analyst Dec 06 '19 at 05:38
  • @Gupta Now my both pages are angular. still the browser is paused and waiting for angular variables. Can you help me in this case – Analyst Dec 11 '19 at 07:57
  • The script fails after jasmine.default time.. it says default jasmine time out – Analyst Dec 17 '19 at 15:05
  • Addittionally.. there is an error like waiting for angular.. time expired... although the app is developed purely in angular 4 – Analyst Dec 17 '19 at 15:07
  • Umm..If its an pure angular app then no need of using "waitForAngularEnabled(true)". And for time expired occurs in case of IE due to async script. Refer this https://stackoverflow.com/a/19411262/1976848 – Himanil Gupta Dec 18 '19 at 12:26
  • I am using Chrome, the default browser for protractor, and expiry time is more than enough i.e. 15 mins. All the things mentioned in reference link are already there in my script – Analyst Dec 19 '19 at 05:39
  • Can you please share an error stack trace and code snippet related to it, which gives some clearer idea of what you are facing and will come up with a proper solution. – Himanil Gupta Dec 19 '19 at 11:16
  • I am sharing the error log **should check fields/button shown to user - Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)** – Analyst Dec 31 '19 at 08:01
  • Even if I increase the default jasmine time out up to 15 min, it still waits and after 15 mins it throws the same error – Analyst Dec 31 '19 at 08:02