protractor
protractor copied to clipboard
Safari Technology Preview can't find Angular 1
Starting with the Release 19, Safari Technology Preview is incompatible with Protractor.
See https://webkit.org/blog/7093/release-notes-for-safari-technology-preview-19/:
Changed
window.nameto be cleared after a cross-origin navigation (r209076)
So if we try to test an Angular 1 app there, we get angular never provided resumeBootstrap.
I wish we didn't need the Preview in the first place and could just use the release version of Safari 10, but the web driver implementation in the release is broken. Specifically, visibility checks aren't implemented in it, which has been fixed in the preview.
Protractor 4.0.14 (tried 5.0.0 too), Node 6.9,4, Selenium Standalone Server 3.0.1, macOS 10.12
Well, that's not good.
On the other hand, it has navigator.webdriver set to true when WebDriver is active. So my current workaround is
if (navigator.webdriver) {
window.name = "NG_DEFER_BOOTSTRAP!" + window.name;
}
before calling angular.bootstrap.
So, the root issue with Safari is "window.name leaks information across domains". Which is true, this is the exact property that Protractor exploits to tell Angular that it's in an E2E test before the browser navigates to the page.
The only way I can see to fix this would be to implement @sjelin's plan for handling browser-initiated navigation, but even that wouldn't totally fix things.
Fundamentally, Protractor depends on some form of cross-domain information leaking so it can signal to Angular that it's running in a test. The alternative would be to load the app (or any page on that domain, I guess) and set something in sessionStore, then reload the app for testing. Alternately, Protractor could use a proxy to inject javascript before the app loads.
This appears to be an issue now in Chrome 63 (which is in the beta channel) as well
@heathkit I think this is going to become a much more prevalent issue very soon...
Any news about this issue? We currently use Protractor 5.2.2 with Safari 11.0.3 and we're unable to make it work because of this error.
We have an Angular 1 app and we basically cannot run our tests for Safari, which represents a great portion of our user base.
Can we conclude that Protractor does not work with Safari 11 for Angular 1 app?
Any workaround or short term solution planned?
Many thanks in advance!
@flo223 I wrote what my workaround was. Does it not work for you?
@thorn0 where did you place your if (navigator.webdriver) { window.name = "NG_DEFER_BOOTSTRAP!" + window.name; } ??
@GiovanyR Before the angular.bootstrap call.
@thorn0 : Do you have an example where i can look?
I'm trying a possible solution that could be written inside the protractor configuration file.
@evilaliv3 It can't be written there. It's something you need to do in the app code before bootstrapping AngularJS. I didn't touch those things for years and have no idea whether that workaround still works.
This same breakage also occurs in Firefox 86
- https://github.com/angular/angular.js/issues/17117
- https://bugzilla.mozilla.org/show_bug.cgi?id=1700931
There's an intent to similarly break this in Chromium. Do y'all have plans to stop relying on window.name for cross-site communication?
@yoavweiss not at this time. We need to come up with some...