-
Notifications
You must be signed in to change notification settings - Fork 2.3k
"Detected a page unload event" error in phantom.js #85
Comments
I wasn't able to get protractor to work with plain Is there any insight into this error? |
Haven't seen this one before and I can't reproduce it - do you see the chrome window pop up when you're running tests? |
@juliemr is it working with |
I've dug a bit deeper into the issue, and tracked it down to this code
I think what happens here is that |
@juliemr there should be no chrome windows because it's phantomjs. Same issue here. It sometimes throws that exception. |
Ditto, same issue here with PhantomJS. The error manifests itself intermittently. Seems that if I wait long enough between test runs there are no errors. Strange because I have checked that the selenium process has terminated properly. |
Seems to be a timing issue. My coworker has a newer Macbook Air than I do which is much faster and he cannot reproduce the error. Our tests are also automated and idiot-proof so that our node webserver and the selenium server are started immediately before running the tests and shutdown immediately afterwards. After modifying the process so that the node webserver and selenium are kept running between test runs the error goes away. |
👍 I'm seeing this on about 80% of test runs from my machine with Phantom |
I was getting this 100% of the time on my latest macbook air with 8gb ram and phantom 1.9.1 |
I'm also on the latest MacBook Air with 8gb of ram and I'm now getting it more like 95% of the time. On Wed, Sep 18, 2013 at 4:48 PM, Alex Gorbatchev [email protected]
|
I'm seeing it a lot on a retina Macbook Pro. Close to 95% of the time. |
Given that protractor was working fine for me last week, I suspect that one of its transitive dependencies has updated and effectively broken it. When I don't get this error, I get timeouts. On Wed, Sep 18, 2013 at 5:27 PM, seubert [email protected] wrote:
|
Also, important to mention, I have no problems when using Alex Gorbatchev On Wed, Sep 18, 2013 at 2:28 PM, Justin Searls [email protected]:
|
Thanks for all the reports - I'll do some playing around with phantomjs and see if I can reproduce reliably. |
Anyone have any workarounds for this? Very disappointing. |
Also am running into this almost all the time on a really nice Mac Mini. |
FWIW, I was able to change the message by manually wiping out I'm getting a timeout now instead, but not the page unloaded error. |
I'm still having the same issue with 2.35.0 |
+1 for this. With ptor.sleep() I was able to get it to work once but only once (so it seems inconsistent - works once and awhile but not reliably) - it does seem to be a timing issue as it works fine with chromedriver but not with PhantomJS. I also got an Angular not loaded (or similar) error with PhantomJS. |
@juliemr I get the same issue with phantomjs.Otherwise my tests are running fine with chrome and firefox. But my long term goal is to opt for headless browser testing for the continuous CI. Below is the error detail that i get. UnknownError: Error Message => 'Detected a page unload event; asynchronous script execution does not work across page loads.' |
👍 I'm having the same error as well |
It works for me. Make sure you have:
|
@lucassus the config is correct. The error happens once in two or three runs. More seldom on fastest computers. |
@lucassus I get the following error when i execute phantomjs --webdriver=4444 phantomjs --webdriver=4444 Can you elaborate the steps how we initiate the phantomjs using the protractor itself. |
@lucassus I made sure both of them is present, the same thing happened over and over. My comp is pretty fast so I doubt it would be because of computer speed or something.. |
UPDATE: It doesn't work reliable.
But when protractor starts the jar it doesn't work. My relevant proctractor-e2e.config.js
|
Same problem here with PhantomJS and IE drivers. this.driver.get('about:blank');
this.driver.executeScript(
'window.name = "' + DEFER_LABEL + '" + window.name;' +
'window.location.href = "' + destination + '"'); with this.driver.executeScript('window.name = "' + DEFER_LABEL + '" + window.name;');
this.driver.get(destination); But then it does not work anymore with Chrome and Firefox drivers. HTH |
Pretty ugly hack below. protractor.js: var driver = this.driver;
this.getCapabilities().then(function (capabilities) {
if (capabilities.caps_.browserName === 'phantomjs') {
driver.executeScript('window.name = "' + DEFER_LABEL + '" + window.name;');
driver.get(destination);
} else {
driver.get('about:blank');
driver.executeScript(
'window.name = "' + DEFER_LABEL + '" + window.name;' +
'window.location.href = "' + destination + '"');
}
// Make sure the page is an Angular page.
driver.executeAsyncScript(clientSideScripts.testForAngular, 10).
then(function(hasAngular) {
if (!hasAngular) {
throw new Error('Angular could not be found on the page ' +
destination);
}
});
}); |
The hack seems to not only fix my issue but also speed up my test suite! |
I also can't get a basic PhantomJS suite to execute properly. I haven't even gotten to the 'page unload' issue yet. Here's my basic setup: referenceConf.js
driver/ptor setup similar to @alexgorbatchev at top of thread. I have PhantomJS setup locally with: Run Phantom in a separate thread: Run selenium in a separate thread: Run my tests in a separate thread. I'm using Grunt-Protractor-Runner.
Results. I have have a few logs to help debug.
The tests kick off, by none of the ptor functionality seems to be working in my I'm running Selenium and Selenium-WebDriver 2.37.0 and have PhantomJS 1.9.2. Any ideas appreciated. Also, there's another issue thread running over here #189 where we are trying to document how to get Phantom running. |
This worked for me.
|
@sdeering The patch you linked to solved the problem for me. PhantomJS 1.9.2; node 0.10.23. |
same for me...maybe this patch should become a pull request... |
Yeah probably a good idea. |
@juliemr pls, apply this patch. |
@sdeering's workaround works for me too. 👍 Edit: Just noticed I had phantomjs 1.9.1 installed (via homebrew). A |
After running with phantomjs 1.9.2 successfully quite a bit, I now got one of those random died browser thingies:
Full stack trace at https://gist.github.com/tfnico/8471223 - seems like a phantomJS/webdriver issue though: detro/ghostdriver#140 |
@tfnico: I've been using PhantomJS/GhostDriver with the Java selenium bindings for around a year now and I can confirm that that error is one that does occur from time to time. So, you're right in that it probably has nothing to do with Protractor. |
Running the same test on my little old i3 laptop with Ubuntu at home leads to the 'Detected a page unload event...' problem again (with phantomjs 1.9.2, protractor 0.16.1) consistently. This could be related to ariya/phantomjs#11901 which already links to this issue. However, I do not have the hotfix in my lib/protractor.js discussed there and earlier here. After installing the hotfix, on the other hand, I now get "angular never provided resumeBootstrap" when doing browser.get's. Or I get timeouts. Feels a bit shaky 🎱 Just to recap: On the Mac, everything works. On Ubuntu, Chrome works, but phantomjs fails as described above. On a related note, on Debian (our CI environment), phantomjs crashes consistently mid-test (I'll report that to them next week). |
could any help me out with setting up protractor to run phantomJS on a Mac, any time I try to run it i get the following error:
Command duration or timeout: 3 milliseconds not sure if it is something with my setup or not. Thank you |
@juliemr Thanks for fixing it!! Hopefully protractor and phantomjs/ghostdriver will play nicely together from now on. |
Fix will be out in 0.17.0, and I'll as everyone to hit it as hard as they On Thu, Jan 23, 2014 at 3:09 AM, Renan Martins [email protected]:
|
FWIW, I am seeing the same sorts of problem in both Chromedriver and in Firefox: some % percentage of time, when an executeAsyncScript call times out, the browser reloads the page (perhaps having crashed). Oddly enough it happens at the very end of the timeout period. It's still an issue in those environments, as of 11/13/14 . Is it still an issue in phantomJS? |
Hi myklemykle, |
This issue needs to be re-open. The problem still exists Uncaught exception: Error while running testForAngular: {"errorMessage":"Detected a page unload event; asynchronous script execution does not work across page loads.","request":{"headers":{"Accept-Enc |
I confirm the issue still exists
Here is the error:
|
Still is not working correctly when you have windows authentication or NTLM in place. The http://username:password@dns is working using PhantomJs but from Protractor it raise the same error. |
When trying to use the lates version of Angular with PhantomJS we get a message complaining about "Detected a page unload event". This was fixed in earlier versions of Angular, see issue angular#85, but reappeared now. The problem is that using data urls to reset the page causes this issue, so we have to do as we do with Safari and use "about:blank" instead
I submitted a Pull request to solve this in the latest versions of Angular |
When trying to use the lates version of Angular with PhantomJS we get a message complaining about "Detected a page unload event". This was fixed in earlier versions of Angular, see issue #85, but reappeared now. The problem is that using data urls to reset the page causes this issue, so we have to do as we do with Safari and use "about:blank" instead
Trying to run "onMocha.js" example with phantomjs or chromedriver doesn't seem to work.
Here's the code, I only changed
webdriver.Capabilities.chrome()
towebdriver.Capabilities.phantomjs()
andexpect.js
tochai
Here's the error
phantom
The text was updated successfully, but these errors were encountered: