-
Notifications
You must be signed in to change notification settings - Fork 2.3k
chore(core): Add better error message for client-side redirects #2643
Comments
@sjelin would you please explain a bit more on what can be done to mitigate this problem? My use case: I have a test that enters username/password and hits a log in button, that redirects to another page on successful log in. |
If both pages are angular pages, you should just add a |
We're working on a feature to make this better in the future |
I've been struggling with this issue for a week now. |
That's good to keep in mind, thanks. For now, you could probably mitigate the problem by just having your test wait a few hundred milliseconds after the client side redirect occurs. This will stop Protractor from throwing the error message, though it wouldn't allow Protractor to bootstrap properly so it may cause some other unexpected problems (especially if you're using plugins or mock modules). |
Actually, I'm using something like this as workaround where I know there will be a redirection:
|
@tassoevan, that's perfect! It's what I'd expect waitForAngular to do - wait for angular to be available. |
When protractor starts, it always goes to the baseUrl then my test page. Is that considered the redirect you are talking about? |
Not quite @patrickliechty, I mean when you click on a link (like |
@sjelin , is this issue still exists in protractor 3.1.1.I can see that one |
+1 for a better fix. Ran into this today with no idea how to reliably work-around it. Thanks! |
Having the same Issue!!! thanks @tassoevan for a reliable fix |
+1 for a fix. |
I got this error by doing element().getText() outside of the specs (without a browser.get() having occurred) -- was trying to create a shortcut for the output of a particular div outside the specs. Turned it into a function and all was well. |
I get this error when running against \node_modules\protractor\example\conf.js, surely the example conf.js should always work regardless?? |
For people using Protractor without Angular, is there a workaround ? |
@Overdrivr You can set browser.ignoreSynchronization = true; to tell Protractor to not wait for Angular. |
browser.ignoreSynchronization = true works for me when i switch windows. |
I am getting this without
|
@tassoevan hi dude, could you tell me how to config that browser.wait() like your description and where to config it
|
in angular (2) - Make sure your spec begins w/ browser.get('/');
|
After looking at @tassoevan's great workaround and getting my redirect tests working, I figured I'd share my TypeScript and Angular2 solution. I put this function on my abstract page class, but I think it might fit better on the
Here's an example of how I used it in a test:
|
My login page is non-Angular js page. Once i login to the application Angular js page is created. So I created spec file as given below: describe('Login to Application', function() { function loginToApplication(stringSSOID, stringPassword) { } beforeEach(function() { it('have login to application', function() { Getting below error message: |
Hi take a look at http://www.protractortest.org/#/timeouts#how-to-disable-waiting-for-angular |
I realize it's a lengthy discussion already, but this might help someone. Such an error message can also happen when the page is reloading unexpectedly because of an unhandled error happening in an Angular component. The fact that browser console may not be persisted, together with how fast the tests execute made it quite not-straightforward for me to understand what was going on. So maybe something could be done as far as the error message is concerned, since the aforementioned case is not 'client side navigation' per se :) |
Hi @ArnaudPel Tnx for your extra info. Maybe you can add a PR to explain this in the docs if you want? |
I currently get this error when doing the trip to our login page (a common problem):
Doing the browser.ignoreSynchronization = true;
// do work here with browser.driver
browser.ignoreSynchronization = false; The link lands here at this thread, but what to do next is not exactly clear. Tested with Protractor versions: 5.2.1, 5.1.1, 5.1.0, 5.0.0 |
@benjaminapetersen - You could try using |
I tried
|
@thompsnm thanks! Though it looks like waitForAngularEnabled is also deprecated.... |
@benjaminapetersen that deprecated doc tag is on the |
waitForAngularEnabled doesn't work for me either. It worked with IgnoreSynchronization before upgrading to Protractor 5. I need to switch into non-Angular iframe, and now I can't. Please advise. Thanks |
@seel93 Try commenting
Note: I have |
|
I just solved my issue. 🥇 Root cause: Developer console side effect |
I was having this problem and the fix for me ended up being to change to protractor "^5.3.2" in my package.json |
I have a regular login page and then I redirect to angular page. So I don't exactly know how or why it works, because I'm really new to angular and angular e2e, but I got it working once I used the
Hope it helps. |
That last solution almost work for me unless I got an error after the test passes : |
Yes, it's irrelevant for us, but it works at least (exit code 0), avoiding the so frustrating error described here : angular/protractor#2643. Maybe some refactoring is possible, but first we need to modify tests to make them reflect our needs. Stay tuned.
Yes, it's irrelevant for us, but it works at least (exit code 0), avoiding the so frustrating error described here : angular/protractor#2643. Maybe some refactoring is possible, but first we need to modify tests to make them reflect our needs. Stay tuned.
It works for anything, you can't use more than one 'element().anyfunction()' outside an ' it '. |
Got error when switch from one web page to another in Protractor: Failed: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details" the code is : |
I started getting this error suddenly my CT builds. I noticed that this error occurs only with Firefox headless and worked fine with Chrome headless on Linux. I upgraded from Firefox v69 to the latest one (v72.0.2 at the moment) which fixed this issue. |
If you want to use it in a way that you can disable and enable
|
I'm currently hitting this error: Exception has occurred: Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details" But only when trying to debug through either VS Code debugger or chrome inspector debug (followed the instructions here for both cases https://www.protractortest.org/#/debugging). Here's my {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "E2E Test",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\node_modules\\protractor\\bin\\protractor",
"args": ["${workspaceFolder}\\e2e\\protractor.conf.js"],
"outFiles": [
"${workspaceFolder}/e2e/**/*.js",
"${workspaceFolder}/src/**/*.js"
]
}
]
} Maybe it's something I have set up wrong. Any help is appreciated, trying to write these without being able to properly debug is insanely difficult. |
If the test clicks a link or something which causes a redirect outside of
browser.get
orbrowser.refresh
, then the next timewaitForAngular
is called the user will probably run into this error message (since we didn't wait for Angular to load), which is not very helpful.Users should be told what's going wrong and about potential work-arounds (e.g. using
browser.get
orbrowser.refresh
to fix the bootstrapping).The text was updated successfully, but these errors were encountered: