0
votes

Starting page angular. By clicking a button will lead to the login page which is None-angular. After login rest of the pages are angular.

I'm using async/await.

  • Include waitForAngularEnable(true) in onPrepare but didn't work.
  • Try adding waitForAngularEnable(true) after login and this didn't work.
  • Tried with increasing the timeOut and that didn't work too.
  • Works only when waitForAngularEnable(false). I can't use the inbuilt feature in protractor waiForAngular which wait until angular to load. Currently with waitForAngularEnable(false) I'm manually handling it using browser.driver.wait(until.elementsLocated(by.id(value)), 30000); or await browser.wait(ExpectedConditions.presenceOf(ele), 30000);. This way it works.

Versions-
"protractor": "^5.4.2"
"node" : 10.15.3
"target": "es6"
"cucumber": "^5.1.0",
"cucumber-html-reporter": "^5.0.0"
ScriptTimeoutError: script timeout: result was not received in 30 seconds
(Session info: chrome=74.0.3729.169)
(Driver info: chromedriver=74.0.3729.6
(255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17763 x86_64) at Object.checkLegacyResponse
(C:\Automation\General\node_modules\selenium-webdriver\lib\error.js:546:15) at parseHttpResponse (C:\Automation\General\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Automation\General\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7) From: Task: Protractor.waitForAngular() - Locator: By(xpath, //span[@class='title__subtext'])

3
If it works then what is your problem. You will have to set waitForAngularEnable(false) for Non-Angular pages. - Nitin Sahu
I can't use the inbuilt feature in protractor waiForAngular which wait until angular to load. Currently with waitForAngularEnable(false) I'm manually handling it using browser.driver.wait(until.elementsLocated(by.id(value)), 30000); or await browser.wait(ExpectedConditions.presenceOf(ele), 30000);. This way it works. - ramindusn

3 Answers

0
votes

What you are doing (per my understanding of your problem)

  • open angular page
  • login
  • you're redirected to non-angular page (at this point protractor already not responding)
  • you try await browser.waitForAngularEnabled(false); (but protractor doesn't respond because you're on non-angular page)

What you should be doing

  • open angular page
  • enter credentials
  • before you click submit button run await browser.waitForAngularEnabled(false);
  • you're redirected to non-angular page (at this point protractor can communicate with it)
  • do whatever you want to do

Simply, you have to disable waiting for angular WHILE you're still on angular page

P.S. and vice versa. if you're navigating from non-angular page back to angular, you must enable the feature only when you landed on angular page

0
votes

Using waitForAngularEnabled multiple times in the same test can be done, but requires a non-obvious addition of browser.get. You can use the following:

// do things on your Angular application

waitForAngularEnabled(false)

// do things on non-angular page

waitForAngularEnabled(true)
browser.get('/home') // this is a page from your Angular application

The browser.get function blocks until the Angular page is loaded.

-1
votes

For Angular apps, Protractor will wait until the Angular Zone stabilizes. This means long-running async operations will block your test from continuing. To work around this, run the following tasks outside of the Angular Zone.

Probably you need to set this timeout as a patch until the issue is fixed in application level

allScriptsTimeout: 60000

Found a good article on this: https://valor-software.com/articles/testing-with-protractor-how-to-fix-synchronization-issues.html