Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

"Detected a page unload event" error in phantom.js #85

Closed
alexgorbatchev opened this issue Sep 12, 2013 · 72 comments
Closed

"Detected a page unload event" error in phantom.js #85

alexgorbatchev opened this issue Sep 12, 2013 · 72 comments

Comments

@alexgorbatchev
Copy link

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() to webdriver.Capabilities.phantomjs() and expect.js to chai

/**
 * This example shows how to use the protractor library in a Mocha test.
 * It assumes that a selenium server is running at localhost:4444.
 * Run this test with:
 *   mocha onMocha.js
 */

var util = require('util');
var expect = require('chai').expect;
var webdriver = require('selenium-webdriver');
var protractor = require('../lib/protractor.js');

describe('angularjs.org homepage', function() {
  this.timeout(80000);

  var driver, ptor;

  before(function() {
    driver = new webdriver.Builder().
        withCapabilities(webdriver.Capabilities.phantomjs()).build();

    driver.manage().timeouts().setScriptTimeout(10000);
    ptor = protractor.wrapDriver(driver);
  });

  after(function(done) {
    driver.quit().then(function() {done()});
  })

  it('should greet using binding', function(done) {
    ptor.get('http://www.angularjs.org');

    ptor.findElement(protractor.By.input('yourName')).sendKeys('Julie');

    ptor.findElement(protractor.By.binding('{{yourName}}')).
        getText().then(function(text) {
          expect(text).to.eql('Hello Julie!');
          done();
        });
  });

  ... snip
});

Here's the error

Uncaught UnknownError: Error Message => 'Detected a page unload event; asynchronous script execution does not work across page loads.'
 caused by Request => {"headers":{"Accept":"application/json; charset=utf-8","Connection":"keep-alive","Content-Length":"425","Content-Type":"application/json;charset=UTF-8","Host":"192.168.128.240:56087"},"httpVersion":"1.1","method":"POST","post":"{\"script\":\"return (function () {\\n  var attempts = arguments[0];\\n  var callback = arguments[arguments.length - 1];\\n  var check = function(n) {\\n    if (window.angular && window.angular.resumeBootstrap) {\\n      callback(true);\\n    } else if (n < 1) {\\n      callback(false);\\n    } else {\\n      window.setTimeout(function() {check(n - 1)}, 1000);\\n    }\\n  };\\n  check(attempts);\\n}).apply(null, arguments);\",\"args\":[10]}","url":"/execute_async","urlParsed":{"anchor":"","query":"","file":"execute_async","directory":"/","path":"/execute_async","relative":"/execute_async","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute_async","queryKey":{},"chunks":["execute_async"]},"urlOriginal":"/session/e2dbebc0-1b3f-11e3-84c0-67b730e3988e/execute_async"}
      at new bot.Error (./node_modules/selenium-webdriver/lib/atoms/error.js:109:18)
      at Object.bot.response.checkResponse (./node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
      at ./node_modules/selenium-webdriver/lib/webdriver/webdriver.js:275:20
      at ./node_modules/selenium-webdriver/lib/goog/base.js:1178:15
      at webdriver.promise.ControlFlow.runInNewFrame_ (./node_modules/selenium-webdriver/lib/webdriver/promise.js:1438:20)
      at notify (./node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
      at notifyAll (./node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
      at fulfill (./node_modules/selenium-webdriver/lib/webdriver/promise.js:402:7)
      at ./node_modules/selenium-webdriver/lib/webdriver/promise.js:1305:10
      at ./node_modules/selenium-webdriver/lib/goog/base.js:1178:15
      at webdriver.promise.ControlFlow.runInNewFrame_ (./node_modules/selenium-webdriver/lib/webdriver/promise.js:1438:20)
      at notify (./node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
      at notifyAll (./node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
      at fulfill (./node_modules/selenium-webdriver/lib/webdriver/promise.js:402:7)
      at ./node_modules/selenium-webdriver/lib/goog/base.js:1178:15
      at webdriver.promise.ControlFlow.runInNewFrame_ (./node_modules/selenium-webdriver/lib/webdriver/promise.js:1438:20)
      at notify (./node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
      at notifyAll (./node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
      at fulfill (./node_modules/selenium-webdriver/lib/webdriver/promise.js:402:7)
      at ./node_modules/selenium-webdriver/lib/webdriver/promise.js:607:51
      at ./node_modules/selenium-webdriver/lib/webdriver/http/http.js:96:5
      at IncomingMessage.<anonymous> (./node_modules/selenium-webdriver/http/index.js:113:7)
      at IncomingMessage.EventEmitter.emit (events.js:117:20)
      at _stream_readable.js:895:16
      at process._tickCallback (node.js:415:13)
  ==== async task ====
  WebDriver.executeScript()
      at webdriver.WebDriver.schedule (./node_modules/selenium-webdriver/lib/webdriver/webdriver.js:266:15)
      at webdriver.WebDriver.executeAsyncScript (./node_modules/selenium-webdriver/lib/webdriver/webdriver.js:506:15)
      at Protractor.get (./node_modules/protractor/lib/protractor.js:556:15)
      at Context.<anonymous> (./node_modules/protractor/example/onMocha.js:32:10)
      at Test.Runnable.run (./node_modules/protractor/node_modules/mocha/lib/runnable.js:194:15)
      at Runner.runTest (./node_modules/protractor/node_modules/mocha/lib/runner.js:355:10)
      at ./node_modules/protractor/node_modules/mocha/lib/runner.js:401:12
      at next (./node_modules/protractor/node_modules/mocha/lib/runner.js:281:14)
      at ./node_modules/protractor/node_modules/mocha/lib/runner.js:290:7
      at next (./node_modules/protractor/node_modules/mocha/lib/runner.js:234:23)
      at Object._onImmediate (./node_modules/protractor/node_modules/mocha/lib/runner.js:258:5)
      at processImmediate [as _immediateCallback] (timers.js:317:15)

phantom

> phantomjs --version                                                                                                                                                                                            
1.9.1
@alexgorbatchev
Copy link
Author

I wasn't able to get protractor to work with plain chromedriver nor phantomjs... the only thing that worked was standalone selenium driver as per the doc.

Is there any insight into this error?

@juliemr
Copy link
Member

juliemr commented Sep 12, 2013

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?

@alexgorbatchev
Copy link
Author

@juliemr is it working with phantomjs for you? I'm trying to setup e2e tests for our CI environment and really, really want to use protractor instead of karma and old e2e :( I can't use chromebecause of this.

@alexgorbatchev
Copy link
Author

I've dug a bit deeper into the issue, and tracked it down to this code

Protractor.prototype.get = function(destination) {
  destination = url.resolve(this.baseUrl, destination);

  this.driver.get('about:blank');
  this.driver.executeScript('window.name += "' + DEFER_LABEL + '";' +
      'window.location.href = "' + destination + '"');

  // Make sure the page is an Angular page.
  this.driver.executeAsyncScript(clientSideScripts.testForAngular, 10).
    ...

I think what happens here is that window.location.href triggers page unload for the current about:blank while testForAngular is waiting for angular framework... apparently phantomjs doesn't like that. Any suggestions?

@meze
Copy link

meze commented Sep 17, 2013

@juliemr there should be no chrome windows because it's phantomjs.

Same issue here. It sometimes throws that exception.

@kwo
Copy link

kwo commented Sep 17, 2013

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.

@kwo
Copy link

kwo commented Sep 18, 2013

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.

@searls
Copy link

searls commented Sep 18, 2013

👍 I'm seeing this on about 80% of test runs from my machine with Phantom

@alexgorbatchev
Copy link
Author

I was getting this 100% of the time on my latest macbook air with 8gb ram and phantom 1.9.1

@searls
Copy link

searls commented Sep 18, 2013

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 notifications@github.com
wrote:

I was getting this 100% of the time on my latest macbook air with 8gb ram and phantom 1.9.2

Reply to this email directly or view it on GitHub:
#85 (comment)

@seubert
Copy link

seubert commented Sep 18, 2013

I'm seeing it a lot on a retina Macbook Pro. Close to 95% of the time.

@searls
Copy link

searls commented Sep 18, 2013

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 notifications@github.com wrote:

I'm seeing it a lot on a retina Macbook Pro. Close to 95% of the time.

Reply to this email directly or view it on GitHub:
#85 (comment)

@alexgorbatchev
Copy link
Author

Also, important to mention, I have no problems when using
selenium+chromedriver or even saucelabs service. This problem seems to be
specific to phantomjs :(

Alex Gorbatchev
(650) 931-5954

On Wed, Sep 18, 2013 at 2:28 PM, Justin Searls notifications@github.comwrote:

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 notifications@github.com
wrote:

I'm seeing it a lot on a retina Macbook Pro. Close to 95% of the time.

Reply to this email directly or view it on GitHub:
#85 (comment)


Reply to this email directly or view it on GitHubhttps://github.com//issues/85#issuecomment-24701034
.

@juliemr
Copy link
Member

juliemr commented Sep 19, 2013

Thanks for all the reports - I'll do some playing around with phantomjs and see if I can reproduce reliably.

@seubert
Copy link

seubert commented Sep 23, 2013

Anyone have any workarounds for this? Very disappointing.

@iameli
Copy link

iameli commented Sep 25, 2013

Also am running into this almost all the time on a really nice Mac Mini.

@searls
Copy link

searls commented Sep 25, 2013

FWIW, I was able to change the message by manually wiping out node_modules/selenium-webdriver and npm install selenium-webdriver@2.35.0 (2.35.1 had been installed).

I'm getting a timeout now instead, but not the page unloaded error.

@seubert
Copy link

seubert commented Sep 25, 2013

I'm still having the same issue with 2.35.0

@lukemadera
Copy link

+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.

@ranjanbhambroo
Copy link

@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.'
caused by Request => {"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"425","Content-Type":"application/json; charset=utf-8","Host":"localhost:33735"},"httpVersion":"1.1","method":"POST","post":"{"args":[10],"script":"return (function () {\n var attempts = arguments[0];\n var callback = arguments[arguments.length - 1];\n var check = function(n) {\n if (window.angular && window.angular.resumeBootstrap) {\n callback(true);\n } else if (n < 1) {\n callback(false);\n } else {\n window.setTimeout(function() {check(n - 1)}, 1000);\n }\n };\n check(attempts);\n}).apply(null, arguments);"}","url":"/execute_async","urlParsed":{"anchor":"","query":"","file":"execute_async","directory":"/","path":"/execute_async","relative":"/execute_async","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute_async","queryKey":{},"chunks":["execute_async"]},"urlOriginal":"/session/0a38df00-2c72-11e3-a864-e527bed93cbd/execute_async"}
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_51'
Driver info: driver.version: unknown

@wakandan
Copy link

wakandan commented Oct 9, 2013

👍 I'm having the same error as well

@lucassus
Copy link

lucassus commented Oct 9, 2013

It works for me. Make sure you have:

  • browserName: "phantomjs" in the protractor config
  • PhantomJS in running in the WebDriver mode, execute phantomjs --webdriver=4444

@meze
Copy link

meze commented Oct 9, 2013

@lucassus the config is correct. The error happens once in two or three runs. More seldom on fastest computers.

@ranjanbhambroo
Copy link

@lucassus I get the following error when i execute phantomjs --webdriver=4444

phantomjs --webdriver=4444
PhantomJS is launching GhostDriver...
[ERROR - 2013-10-09T14:12:28.535Z] GhostDriver - Main - Could not start Ghost Driver => {
"message": "Could not start Ghost Driver",
"line": 82,
"sourceId": 149829104,
"sourceURL": ":/ghostdriver/main.js",
"stack": "Error: Could not start Ghost Driver\n at :/ghostdriver/main.js:82",
"stackArray": [
{
"sourceURL": ":/ghostdriver/main.js",
"line": 82
}
]
}

Can you elaborate the steps how we initiate the phantomjs using the protractor itself.

@wakandan
Copy link

wakandan commented Oct 9, 2013

@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..

@ceelian
Copy link

ceelian commented Oct 12, 2013

UPDATE: It doesn't work reliable.

If I start

phantomjs --webdriver=4444 

manually in a seperate shell it works.

But when protractor starts the jar it doesn't work.

My relevant proctractor-e2e.config.js

[...]
capabilities: {
    'browserName': 'phantomjs',
    'phantomjs.binary.path':'node_modules/phantomjs/bin/phantomjs'
},
[...]

@bbaia
Copy link

bbaia commented Oct 15, 2013

Same problem here with PhantomJS and IE drivers.
To make it work, I had to change this:

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

@renanmartins
Copy link

Pretty ugly hack below.
I wonder why this difference between how phantomjs and other browsers handle the snippet pointed out by @bbaia

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);
        }
      });
  });

@nathasm
Copy link
Contributor

nathasm commented Oct 29, 2013

The hack seems to not only fix my issue but also speed up my test suite!

@jfroom
Copy link
Contributor

jfroom commented Oct 31, 2013

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

capabilities: {
    'browserName': 'phantomjs'
}

driver/ptor setup similar to @alexgorbatchev at top of thread.

I have PhantomJS setup locally with:
npm install -D phantomjs

Run Phantom in a separate thread:
./node_modules/phantomjs/bin/phantomjs --webdriver=8089
(I tired 4444 and got same issue as @ranjan-bhambroo.)

Run selenium in a separate thread:
PATH="./node_modules/phantomjs/bin:$PATH" ./selenium/start

Run my tests in a separate thread. I'm using Grunt-Protractor-Runner.

PATH="./node_modules/phantomjs/bin:$PATH" grunt test:e2e

Results. I have have a few logs to help debug.

⌘ PATH="./node_modules/phantomjs/bin:$PATH" grunt test:e2e                                                                             3 ↵
Running "protractor:e2e" (protractor) task
Using the selenium server at http://localhost:4444/wd/hub
running protractor.onPrepare.coffee
capabilites phantomjs
running app.spec.coffee
in describe block
in before each block
in it block 1
.in before each block
in it block 2
.in before each block
in it block 3
.in before each block
in it block 4
.in before each block
in it block 5
.in before each block
in it block 6
.in before each block
in it block 7
.

Finished in 0.196 seconds
7 tests, 0 assertions, 0 failures

The tests kick off, by none of the ptor functionality seems to be working in my it Jasmine blocks - so the expect commands never are reached. Perhaps ptor is failing to connect with Phantom. The same setup works fine with chrome.

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.

@sdeering
Copy link

This worked for me.

 1. You need to download manually PhantomJS just put in a local dir.
    http://phantomjs.org/download.html

 2. You also need to apply this patch to fix a known bug.
    https://github.com/vrtdev/protractor/commit/2f18b01378e4f054331df23ce536e4081ee1ccf0

@kelveden
Copy link

@sdeering The patch you linked to solved the problem for me. PhantomJS 1.9.2; node 0.10.23.

@matteosister
Copy link
Contributor

same for me...maybe this patch should become a pull request...

sdeering added a commit to sdeering/protractor that referenced this issue Dec 28, 2013
@sdeering
Copy link

Yeah probably a good idea.

@juliemr juliemr mentioned this issue Jan 14, 2014
@rsboarder
Copy link
Contributor

@juliemr pls, apply this patch.

@tfnico
Copy link

tfnico commented Jan 16, 2014

@sdeering's workaround works for me too. 👍

Edit: Just noticed I had phantomjs 1.9.1 installed (via homebrew). A homebrew upgrade phantomjs later I have 1.9.2, and I haven't seen the error since (ran about 5 times so far).

@tfnico
Copy link

tfnico commented Jan 17, 2014

After running with phantomjs 1.9.2 successfully quite a bit, I now got one of those random died browser thingies:

UnknownError: Error communicating with the remote browser. It may have died

Full stack trace at https://gist.github.com/tfnico/8471223 - seems like a phantomJS/webdriver issue though: detro/ghostdriver#140

@kelveden
Copy link

@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.

@tfnico
Copy link

tfnico commented Jan 18, 2014

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).

@aarkanov
Copy link

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:

 UnknownError: Invalid Command Method - Request => {"headers":{"Accept":"application/json, image/png","Cache-Control":"no-cache","Connection":"Keep-Alive","Host":"localhost:3522"},"httpVersion":"1.1","method":"GET","url":"/alert_text","urlParsed":{"anchor":"","query":"","file":"alert_text","directory":"/","path":"/alert_text","relative":"/alert_text","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/alert_text","queryKey":{},"chunks":["alert_text"]},"urlOriginal":"/session/2d559050-81db-11e3-9e23-1d490116e1de/alert_text"}

Command duration or timeout: 3 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'pc3668.ms.otpp.net', ip: '10.50.36.90', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.6.0_65'
Session ID: 2d559050-81db-11e3-9e23-1d490116e1de
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{platform=MAC, acceptSslCerts=false, javascriptEnabled=true, browserName=phantomjs, rotatable=false, driverVersion=1.0.4, locationContextEnabled=false, version=1.9.2, databaseEnabled=false, cssSelectorsEnabled=true, handlesAlerts=false, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=false, proxy={proxyType=direct}, applicationCacheEnabled=false, driverName=ghostdriver, takesScreenshot=true}]

not sure if it is something with my setup or not.

Thank you

@renanmartins
Copy link

@juliemr Thanks for fixing it!! Hopefully protractor and phantomjs/ghostdriver will play nicely together from now on.

@juliemr
Copy link
Member

juliemr commented Jan 23, 2014

Fix will be out in 0.17.0, and I'll as everyone to hit it as hard as they
can and make sure it's robust :)

On Thu, Jan 23, 2014 at 3:09 AM, Renan Martins notifications@github.comwrote:

@juliemr https://github.com/juliemr Thanks for fixing it!! Hopefully
protractor and phantomjs/ghostdriver will play nicely together from now on.


Reply to this email directly or view it on GitHubhttps://github.com//issues/85#issuecomment-33115040
.

@myklemykle
Copy link

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?

@emyphan
Copy link

emyphan commented Dec 18, 2014

Hi myklemykle,
yes i have the same problem in chrome or firefox by running executeAsyncScript. Can anyone please investigate?
#1651

@lpicquet
Copy link

lpicquet commented Apr 8, 2015

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
oding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"856","Content-Type":"application/json; charset=utf-8","Host":"localhost:26497","User-Agent":"Apache-HttpClient/4.3.2 (java 1.5)"},"htt
pVersion":"1.1","method":"POST","post":"{"args":[5],"script":"try { return (function (attempts, asyncCallback) {\r\n var callback = function(args) {\r\n setTimeout(function() {\r\n
asyncCallback(args);\r\n }, 0);\r\n };\r\n var check = function(n) {\r\n try {\r\n if (window.angular && window.angular.resumeBootstrap) {\r\n callback([true, null]);
\r\n } else if (n < 1) {\r\n if (window.angular) {\r\n callback([false, 'angular never provided resumeBootstrap']);\r\n } else {\r\n callback([false, 'ret
ries looking for angular exceeded']);\r\n }\r\n } else {\r\n window.setTimeout(function() {check(n - 1);}, 1000);\r\n }\r\n } catch (e) {\r\n callback([fals
e, e]);\r\n }\r\n };\r\n check(attempts);\r\n}).apply(this, arguments); }\ncatch(e) { throw (e instanceof Error) ? e : new Error(e); }"}","url":"/execute_async","urlParsed":{"anchor":""
,"query":"","file":"execute_async","directory":"/","path":"/execute_async","relative":"/execute_async","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"
/execute_async","queryKey":{},"chunks":["execute_async"]},"urlOriginal":"/session/680a9110-ddf0-11e4-922a-a7c8111b32ce/execute_async"}}
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_25'
Driver info: driver.version: unknown
[launcher] Process exited with error code 1

@RodolpheGohard
Copy link

I confirm the issue still exists

$ protractor --version
Version 2.0.0

$ ./phantomjs --version
2.0.1-development

Here is the error:

Using the selenium server at http://localhost:4444
[launcher] Running 1 instances of WebDriver
F

Failures:

  1) RMC2 login page should have input fields
   Message:
     Error while running testForAngular: {"errorMessage":"Detected a page unload event; asynchronous script execution does not work across page loads.","request":{"headers":{"Accept":"application/json; charset=utf-8","Connection":"keep-alive","Content-Length":"809","Content-Type":"application/json;charset=UTF-8","Host":"localhost:4444"},"httpVersion":"1.1","method":"POST","post":"{\"script\":\"try { return (function (attempts, asyncCallback) {\\n  var callback = function(args) {\\n    setTimeout(function() {\\n      asyncCallback(args);\\n    }, 0);\\n  };\\n  var check = function(n) {\\n    try {\\n      if (window.angular && window.angular.resumeBootstrap) {\\n        callback([true, null]);\\n      } else if (n < 1) {\\n        if (window.angular) {\\n          callback([false, 'angular never provided resumeBootstrap']);\\n        } else {\\n          callback([false, 'retries looking for angular exceeded']);\\n        }\\n      } else {\\n        window.setTimeout(function() {check(n - 1);}, 1000);\\n      }\\n    } catch (e) {\\n      callback([false, e]);\\n    }\\n  };\\n  check(attempts);\\n}).apply(this, arguments); }\\ncatch(e) { throw (e instanceof Error) ? e : new Error(e); }\",\"args\":[10]}","url":"/execute_async","urlParsed":{"anchor":"","query":"","file":"execute_async","directory":"/","path":"/execute_async","relative":"/execute_async","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute_async","queryKey":{},"chunks":["execute_async"]},"urlOriginal":"/session/225b28f0-e9cb-11e4-ad75-8faceda3cfa1/execute_async"}}
   Stacktrace:
     undefined

Finished in 0.175 seconds
1 test, 1 assertion, 1 failure

[launcher] 0 instance(s) of WebDriver still running
[launcher] phantomjs #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1

@moattarwork
Copy link

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.

carlos-granados pushed a commit to carlos-granados/protractor that referenced this issue Jul 7, 2015
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
@carlos-granados
Copy link

I submitted a Pull request to solve this in the latest versions of Angular

sjelin pushed a commit that referenced this issue Jul 9, 2015
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests