Closed mcalthrop closed 8 years ago
From the stacktrace, it looks like a webdriver session is never being created (async task at WebDriver.createSession()
).
I am running phantomjs 1.9.7-1 and it's working just fine, so it must be somewhere else.
It would be helpful to see the output of your selenium standalone server. Could you run that with webdriver-manager start
and change your configuration to use seleniumAddress: http://localhost:4444/wd/hub
?
Ok, thanks Julie.
Here's the output:
seleniumProcess.pid: 15184
Mar 05, 2014 10:12:38 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.driver to /full/path/node_modules/protractor/selenium/chromedriver
10:12:44.383 INFO - Java: Oracle Corporation 24.45-b08
10:12:44.384 INFO - OS: Mac OS X 10.9.2 x86_64
10:12:44.403 INFO - v2.39.0, with Core v2.39.0. Built from revision ff23eac
10:12:44.572 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: MAC
10:12:44.632 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
10:12:44.633 INFO - Version Jetty/5.1.x
10:12:44.634 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
10:12:44.635 INFO - Started HttpContext[/selenium-server,/selenium-server]
10:12:44.636 INFO - Started HttpContext[/,/]
10:12:44.674 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@71f993c
10:12:44.674 INFO - Started HttpContext[/wd,/wd]
10:12:44.685 INFO - Started SocketListener on 0.0.0.0:4444
10:12:44.685 INFO - Started org.openqa.jetty.jetty.Server@2db45934
10:15:29.843 INFO - Executing: [new session: Capabilities [{phantomjs.cli.args=[--debug=true, --webdriver, --webdriver-logfile=webdriver.log, --webdriver-loglevel=DEBUG], browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]] at URL: /session)
10:15:29.867 INFO - Creating a new session for Capabilities [{phantomjs.cli.args=[--debug=true, --webdriver, --webdriver-logfile=webdriver.log, --webdriver-loglevel=DEBUG], browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]
10:15:29.896 INFO - executable: /full/path/./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs
10:15:29.896 INFO - port: 35651
10:15:29.896 INFO - arguments: [--debug=true, --webdriver, --webdriver-logfile=webdriver.log, --webdriver-loglevel=DEBUG, --webdriver=35651, --webdriver-logfile=/full/path/phantomjsdriver.log]
10:15:29.896 INFO - environment: {}
Error: Option webdriver need a value
10:15:50.280 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '172.16.4.64', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:177)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:113)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:90)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:104)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
at org.openqa10:15:50.293 WARN - Exception: null
Note that I've replaced the actual path in the logs above with /full/path/
.
So from the Error: Option webdriver need a value
message, it looks like the --webdriver
option now needs to have a value assigned to it (previously the parameter was required, but did not need a value assigned to it).
I tried removing it, and also assigning to it the value for the webdriver (--webdriver=http://localhost:4444/wd/hub
), and both had the same result: I was able to get PhantomJS running. Great!
However, Protractor failed on every assertion with the following error:
UnknownError: Error communicating with the remote browser. It may have died.
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'Hostname.local', ip: '172.16.4.64', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: PhantomJSDriver
And the output from webdriver-manager start
included the following:
11:24:27.491 INFO - Executing: [find element: By.id: sign-out] at URL: /session/30e3013c-a159-4c31-adfc-3be450ebed54/element)
[ERROR - 2014-03-05T11:24:27.699Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1394018667695
11:24:28.628 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with id 'sign-out'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"33","Content-Type":"application/json; charset=utf-8","Host":"localhost:39666"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"sign-out\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/b3928c50-a458-11e3-a030-95aefe148b93/element"}}
Command duration or timeout: 404 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', 11:24:28.637 WARN - Exception: {"errorMessage":"Unable to find element with id 'sign-out'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"33","Content-Type":"application/json; charset=utf-8","Host":"localhost:39666"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"sign-out\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/b3928c50-a458-11e3-a030-95aefe148b93/element"}}
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '172.16.4.64', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: unknown
I wonder if there is something else incorrect/missing in the array I am assigning to 'phantomjs.cli.args'
?
Hmmm... I just discovered this in the webdriver-manager start
logs:
2014-03-05T11:45:01 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "http://username:password@localhost:9292/path/to/static1.json"
2014-03-05T11:45:01 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "http://username:password@localhost:9292/path/to/static2.json"
2014-03-05T11:45:01 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "http://username:password@localhost:9292/path/to/service"
2014-03-05T11:45:01 [DEBUG] WebPage - updateLoadingProgress: 10
2014-03-05T11:45:01 [DEBUG] WebPage - evaluateJavaScript result QVariant(QString, "{"status":0,"value":null}")
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/710344B2-2CBA-4B9B-9352-8A016F894B94.dmp
So by the looks of things, PhantomJS is crashing. Which is not good.
I have noticed that on the odd occasion when I run the tests, they actually pass (although I have restricted the tests to just a single one while I'm trying to get PhantomJS running).
For reference, when I run node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs --version
, I get 1.9.7
.
I wonder if the HTTP authentication is causing a problem with PhantomJS.
So far, I have been putting the authentication details in the baseUrl
in protractor.conf.js
:
baseUrl: 'http://http_username:http_password@localhost:9292'
Have dug around, and the only PhantomJS documentation on how to pass in HTTP username and password I could find was here.
So I modified my protractor.conf.js
as follows:
capabilities: {
'phantomjs.binary.path': './node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs',
'phantomjs.cli.args': ['--debug=true', '--webdriver=localhost:4444', '--webdriver-logfile=webdriver.log', '--webdriver-loglevel=INFO'],
"phantomjs.page.settings.userName": 'http_username',
"phantomjs.page.settings.password": 'http_password'
},
I also tried adding the --webdriver=
parameter as well:
'phantomjs.cli.args': ['--debug=true', '--webdriver=localhost:4444', '--webdriver-logfile=webdriver.log', '--webdriver-loglevel=INFO'],
Unfortunately none of the above solves the problems I have been having.
@juliemr, could you let me know what parameters you are passing to PhantomJS via phantomjs.cli.args
?
And are you able to set up an HTTP auth test?
many thanks
Matt
I also see problems with the --webdriver
option. I don't think you should specify that one.
I can add phantomjs.page.settings.userName
and phantomjs.page.settings.password
and my tests still pass.
Can you try testing against a page which doesn't require HTTP auth, to see if we can rule that out? e.g. run this test against http://www.angularjs.org
describe('angularjs homepage', function() {
it('should greet the named user', function() {
browser.get('http://www.angularjs.org');
element(by.model('yourName')).sendKeys('Julie');
var greeting = element(by.binding('yourName'));
expect(greeting.getText()).toEqual('Hello Julie!');
});
});
Good call. I'll try that tomorrow (UK time).
Could you let me know what parameters you are passing to phantom?
Matt
I used the same parameters as you, minus the --webdriver
one, and then I also tried with no parameters.
Ok, I've tried the what you suggested.
It works fine using Chrome, but when using PhantomJS, I still get the message that PhantomJS has crashed.
Here's what I have in my protractor.conf.js
:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
seleniumArgs: ['-browserTimeout=60'],
specs: [
'bug-tester-suite.js'
],
browserName: 'phantomjs',
capabilities: {
'phantomjs.binary.path': './node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs'
},
rootElement: 'body',
onPrepare: function () {
require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('test/results/', true, true));
},
framework: 'jasmine',
jasmineNodeOpts: {
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 30000
}
};
And of course the bug-tester-suite.js
file contains the exact contents you specified above.
Here is the protractor output, run via grunt:
Running "protractor:phantomjs" (protractor) task
------------------------------------
PID: 39204 (capability: phantomjs #1)
------------------------------------
Using the selenium server at http://localhost:4444/wd/hub
angularjs homepage
should greet the named user
Failures:
1) angularjs homepage should greet the named user
Message:
UnknownError: Error communicating with the remote browser. It may have died.
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '192.168.50.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: EventFiringWebDriver
Stacktrace:
UnknownError: Error communicating with the remote browser. It may have died.
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'MattRetina.local', ip: '192.168.50.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.2', java.version: '1.7.0_45'
Driver info: driver.version: EventFiringWebDriver
==== async task ====
WebDriver.executeScript()
at Protractor.waitForAngular (/full/path/node_modules/protractor/lib/protractor.js:407:22)
at Protractor.findElement (/full/path/node_modules/protractor/lib/protractor.js:568:8)
at Object.elementFinder.(anonymous function) [as sendKeys] (/full/path/node_modules/protractor/lib/protractor.js:88:24)
at null.<anonymous> (/full/path/test/config/bug-tester-suite.js:5:39)
at /full/path/node_modules/protractor/jasminewd/index.js:54:12
==== async task ====
at null.<anonymous> (/full/path/node_modules/protractor/jasminewd/index.js:53:12)
at null.<anonymous> (/full/path/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Finished in 6.811 seconds
1 test, 1 assertion, 1 failure
[launcher] Runner Process Exited With Error Code: 1
>>
Fatal error: protractor exited with code: 1
And here is the output from running node_modules/protractor/bin/webdriver-manager start
:
10:41:37.765 INFO - Executing: [new session: Capabilities [{browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]] at URL: /session)
10:41:37.767 INFO - Creating a new session for Capabilities [{browserName=phantomjs, phantomjs.binary.path=./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs}]
10:41:37.773 INFO - executable: /full/path/./node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs
10:41:37.773 INFO - port: 6823
10:41:37.773 INFO - arguments: [--webdriver=6823, --webdriver-logfile=/full/path/phantomjsdriver.log]
10:41:37.773 INFO - environment: {}
PhantomJS is launching GhostDriver...
[INFO - 2014-03-06T10:41:39.450Z] GhostDriver - Main - running on port 6823
[INFO - 2014-03-06T10:41:39.794Z] Session [e64f3ee0-a51b-11e3-8aba-d31758324c72] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
[INFO - 2014-03-06T10:41:39.794Z] Session [e64f3ee0-a51b-11e3-8aba-d31758324c72] - page.customHeaders: - {}
[INFO - 2014-03-06T10:41:39.795Z] Session [e64f3ee0-a51b-11e3-8aba-d31758324c72] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"mac-unknown-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2014-03-06T10:41:39.795Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: e64f3ee0-a51b-11e3-8aba-d31758324c72
10:41:39.799 INFO - Done: /session
10:41:39.810 INFO - Executing: [set script timeoutt: 11000] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/timeouts/async_script)
10:41:39.819 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/timeouts/async_script
10:41:39.855 INFO - Executing: [get: about:blank] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:39.871 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:39.877 INFO - Executing: [execute script: window.name = "NG_DEFER_BOOTSTRAP!" + window.name;window.location.assign("http://www.angularjs.org/");, []] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute)
10:41:39.885 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute
10:41:39.910 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:39.916 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.036 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:40.043 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.161 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:40.169 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.293 INFO - Executing: [get current url] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url)
10:41:40.302 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/url
10:41:40.336 INFO - Executing: [execute async script: return (function () {
var attempts = arguments[0];
var asyncCallback = arguments[arguments.length - 1];
var callback = function(args) {
setTimeout(function() {
asyncCallback(args);
}, 0);
};
var check = function(n) {
try {
if (window.angular && window.angular.resumeBootstrap) {
callback([true, null]);
} else if (n < 1) {
if (window.angular) {
callback([false, 'angular never provided resumeBootstrap']);
} else {
callback([false, 'retries looking for angular exceeded']);
}
} else {
window.setTimeout(function() {check(n - 1)}, 1000);
}
} catch (e) {
callback([false, e]);
}
};
check(attempts);
}).apply(null, arguments);, [10]] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute_async)
10:41:42.120 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute_async
10:41:42.132 INFO - Executing: [execute script: return (function () {
// Continue to bootstrap Angular.
angular.resumeBootstrap(arguments[0]);
}).apply(null, arguments);, [[]]] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute)
10:41:43.336 INFO - Done: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute
10:41:43.348 INFO - Executing: [execute async script: return (function () {
var el = document.querySelector(arguments[0]);
var callback = arguments[1];
try {
angular.element(el).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
} catch (e) {
callback(e);
}
}).apply(null, arguments);, [body]] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c/execute_async)
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/96DD66B3-7F6D-452D-BFD8-B7A3DC11748B.dmp
10:41:46.650 INFO - Executing: [delete session: 6bb308da-46f1-47e2-9b99-57fab05b1e6c] at URL: /session/6bb308da-46f1-47e2-9b99-57fab05b1e6c)
A bit more info... today I actually got it to run about a dozen tests (out of a suite of around 100) before it crashed.
Plus: a colleague tried running it on an up to date Gentoo installation.
Hm. You've reached the limits of my phantomjs knowledge.
Any proxies or firewalls? What's the version of phantomJS at /node_modules/karma-phantomjs-launcher/node_modules/phantomjs/bin/phantomjs
?
Version 1.9.7
. No firewalls or proxies.
I have built a very simple project that works independently of grunt
, so I can hopefully isolate the issue.
Could you have a look at protractor-phantomjs-testing, and see if it always runs ok for you?
I have tried running that several times, and sometimes it works fine, but other times I get the PhantomJS has crashed
message.
I have also tried running the same project on Gentoo and Ubuntu installations, and the same thing happens on both of them: sometimes it works, and other times phantomjs
crashes.
Hi again Julie
Since I made that post, the tests I originally wrote have changed quite a bit: I discovered that when the target location for protractor & phantomjs is a minimal Angular installation, there are no crashes.
However, it consistently fails when testing against www.angularjs.org.
So I wondered if maybe it had something to do with PhantomJS not being able to handle certain font formats, and I designed a set of tests to see what would happen when fonts were included on that minimal AngularJS page – results are on the github project I linked to in my previous message.
Hi Matt,
Yes, I get occasional failures as well using protractor-phantomjs-testing - they seem to only occur when run individually on angularjs.org, but when run together it fails after about the second test. Maybe it's a time-related thing?
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting ....
To test that out, I tried just repeating the 'No fonts' tests a couple times and commenting out all the others. PhantomJS crashes after the third or fourth time. So, not a font thing as far as I can tell.
I can get tests to fail (with the phantomjs crash) occasionally using the following. Note that it doesn't use angular or protractor (just grabs the base webdriver).
describe('showing failures with lots of page reloads and async calls', function () {
it('fails after lots of reloads', function () {
var location = 'http://www.phantomjs.org';
var driver = browser.driver;
function trivialAsyncScript() {
driver.executeAsyncScript(function() {
var callback = arguments[0];
setTimeout(function() {
callback();
}, 500);
});
}
for (var i = 0; i < 20; ++i) {
driver.get(location);
trivialAsyncScript();
}
});
});
I have submitted an issue to ghostdriver: https://github.com/detro/ghostdriver/issues/328
Yes, I've managed to reproduce what you noted in your comment from about 2 hours ago: if you hit the browser with several calls, it doesn't matter if there's a font loaded or not.
So the loading of the font could just be taking a bit more time, which triggers the browser crash earlier.
Any other suggestions?
I think the next step is to post the crash dump as directed here – although I'll have to do this from a Linux crash dump.
Note also that I tried using the Linux binary downloaded from the phantomjs website (onto my Ubuntu installation), and that crashed in the same way the others did.
Just saw your last comment: thanks for the issue submission to detro!
@juliemr: I just created a different project that demonstrates how to consistently crash phantomjs
with Protractor:
https://github.com/mcalthrop/protractor-phantomjs-crash
Check out the results section to see what results I get, and hence what results I'd expect you would get.
Feel free to use this on the detro issue you raised (although I'm not sure if it's useful, as it uses Protractor).
Note that calls to driver.get()
consistently pass, whereas calls to browser.get()
usually fail after about 3 calls.
However, the confusing thing is that on occasions, all the browser.get()
calls succeeded.
I've also raised an issue with phantomjs: https://github.com/ariya/phantomjs/issues/12050
It also crashes on my test with phantomjs & ghostdriver. Looking for the solution
@henrytao-me:
Firstly, how are you determining that phantomjs
has crashed?
The way I knew it was crashing was this line on the output from running node_modules/protractor/bin/webdriver-manager start
:
PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/96DD66B3-7F6D-452D-BFD8-B7A3DC11748B.dmp
Secondly, have you checked out the repo I mentioned above? https://github.com/mcalthrop/protractor-phantomjs-crash
If you get the same results as I described in the results section, then I think it's fair to assume that the problem is with phantomjs
, and not with your tests.
And thirdly, have you created a crash report? I don't know how long it will take them to reply, but it's definitely worth doing. And make sure you convert the crash dump to a stack trace as they describe.
Hi @mcalthrop I face the same problem that you describe in the beginning and I cannot even get phantomjs to run. I point the binary path to a local installation of phantomjs and i tried passing various options in the cli.args with no difference. I still get the same error that you have in your first post and phantomjs never runs. The tests that I try to run are the example specs from protractor. I started a selenium server locally using webdriver-start. Everything works fine for Chrome and Firefox. I know this is still an open issue probably related to phantomjs but would love to get phantomjs at least running. What was the protractor config that resolved this problem? Thanks a lot
@mcalthrop I'm getting the same thing. My tests run find on Chrome and firefox, and occasionaly run ok on phantomjs (1.9.7-1). However, about 70% of the time when I run locally (OSX) they fail with phantomjs having crashed. On my CI server (ubuntu 12.04) phantom seems to crash almost straight away. I wonder if it is some kind of timing issue. Thanks for all the investigative work you've done so far.
Actually managed to get phantomjs working with protractor. @mcalthrop I am running your tests from https://github.com/mcalthrop/protractor-phantomjs-crash and they consistently pass. All of them. I do not get the results you describe. However, the example spec from protractor docs is still failing randomly with: 'Error communicating with the remote browser. It may have died'. Don't know if this will help at all.
@lefos987 I just cloned https://github.com/mcalthrop/protractor-phantomjs-crash afresh and still get the crashes as described. OSX 10.9 , phantomjs 1.9.7-3, protractor 0.20.1
Any idea what you might have different in your setup that could help fix this?
@Bochenski I did not clone the repo but just copied the specs and run them. I am running phantom and protractor in Windows 7.
I did not use npm to install phantomjs but just used the zip that they provide and added the .exe to my PATH. When i was trying to make it work via the npm module I could not even get phantomjs to start.
I run selenium web server via webdriver-manager start
.
In my protractor.conf.js
file I only pass browserName
in the capabilities
. Then I just run protractor with the three tests that I copied over from https://github.com/mcalthrop/protractor-phantomjs-crash. It passes every time. Do you want to try to grab the phantomjs latest installer from here and see if you can install it without npm?
Hi @Bochenski , Can you send your test case? Maybe I can help somehow.
@henrytao-me Thanks for the offer, I'm pretty sure mine is the same issue as demonstrated in this repo by @mcalthrop : https://github.com/mcalthrop/protractor-phantomjs-crash, Clone this repo, then run:
$ npm install
$ node_modules/protractor/bin/webdriver-manager update
In one terminal window, start the webdriver manager:
$ node_modules/protractor/bin/webdriver-manager start
And in another terminal window, run the test specs
$ ./run_all_tests.bash
@lefos987 The phantomjs file installed by npm install is pulled directly from that link, so I don't think that can be the difference. Maybe it's OS related somehow if you're ok running on Windows?
Does any one know when this issue is likely to close ?
We just tested on linux with Phantomjs 2.0 (we had to build it) and this issue still reproduces :(
Reproduced this same error with a few basic tests, works with chrome but phantomjs crashes. Tested on both OSX and Linux. Ran tests from here with the same result https://github.com/mcalthrop/protractor-phantomjs-crash. Versions: OSX 10.9, Phantomjs 1.9.7-15 , protractor 1.0.0, selenium-webdriver@2.42.1 :(
I'm wondering if anyone has successfully gotten Protractor and PhantomJS to play nicely. The minimal sample test from http://angular.github.io/protractor/#/ works perfectly for me in Chrome, Firefox, and Safari, but fails miserably using PhantomJS. The same is true for my actual test suite, which reliably fails on the third test with "PhantomJS has crashed"
I would imagine that SOMEONE has gotten this working, otherwise there wouldn't be a reference to PhantomJS in the documentation. Is there a known version of Protractor/PhantomJS that works?
I tried and totally failed. Then realized.. what was the point of me trying to make PhantomJS work for end-to-end testing?
Final conclusion: I should focus on real browsers for e2e and leave PhantomJS for Karma unit tests.
@elgalu: I have previously had a use-case for it: the CI environment being used on the project I was working on was not able to fire up a browser, so PhantomJS seemed the ideal solution – until I couldn't get it to work. They ended up changing the CI env so that we could fire up Firefox.
Well I use phantom and protractor in my Jenkins e2e test flow and it works fine. Tommorow I will post my conf and versions.
I agree @mcalthrop, many folks seem to be going through similar try & fail path. I use a headless selenium server in the cloud, it provides Chrome & Firefox even though there is no real DISPLAY. I've just moved the config files here: https://github.com/elgalu/headless
Please do @manuelmazzuola that would be awesome!
We're facing the same errors using protractor and phantomjs on Linux. It would be great to get these problems ironed out.
For now, we're falling back to using Chrome and Firefox in headless mode.
Currently I have: protractor@0.24.2 phantomjs@1.9.7-15 selenium-webdriver@2.42.0 karma-phantomjs-launcher@0.1.4 grunt-protractor-runner@1.0.1 protractor-screenshot-reporter@0.0.5 (usefull for doing screenshots during the tests if something going wrong) node v0.10.31
Protractor.conf.js
var ScreenShotReporter = require('protractor-screenshot-reporter');
var path = require('path');
exports.config = {
specs: ['test/e2e/**/*.js'],
baseUrl: 'http://localhost:9001',
framework: 'jasmine',
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.42.0.jar',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
isVerbose : true,
includeStackTrace : true
},
capabilities: {
browserName: 'phantomjs',
'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs',
'phantomjs.cli.args': ['--ignore-ssl-errors=true', '--web-security=false']
},
onPrepare: function() {
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('', true, true, 'e2e-results', true)
);
jasmine.getEnv().addReporter(new ScreenShotReporter({
baseDirectory: './test/e2e/screenshots',
pathBuilder: function pathBuilder(spec, descriptions) {
return path.join(descriptions.join('-').replace(/\s+/g, '-'));
}
}));
},
allScriptsTimeout: 20000
}
Grunt task
grunt.registerTask('test:e2e', [
'clean:server',
'concurrent:test',
'autoprefixer',
'run-sql:create-test-db', <-- create DB
'run:cargo_start', <-- start my java backend
'run-sql:populate-test-db', <-- insert data into the DB
'connect:test',
'protractor:run',
'run:cargo_stop' <-- stop the java backend
]);
...
protractor: {
options: {
keepAlive: true,
configFile: 'protractor.conf.js'
},
run: {}
},
...
Jenkins flow:
npm install
./node_modules/protractor/bin/webdriver-manager update
grunt test:e2e
And all works very fine :+1:
@manuelmazzuola Is it running on Linux? If so, what distro and version? Or on Mac or a different platform?
@adamfeuer On my ultrabook I have Archlinux, a rolling release distro, and the jenkins server has ubuntu 12.04.3 LTS.
Having the same issue. Consistently fails when running using phantomjs but not chrome.
Tried the following but doesn't seem to do anything.
beforeEach(function(){
browser.driver.manage().window().setSize(1280, 1024);
});
This is a simple test that works with my configuration (protractor and phantom)
//
// test/e2e/base/registration.js
//
'use strict';
var $p;
describe('E2E Registration', function() {
beforeEach(function() {
$p = protractor.getInstance();
browser.ignoreSynchronization = true;
browser.driver.manage().window().setSize(1280, 1024);
});
it('should register a user', function() {
browser.get('/#/register');
$p.sleep(3000);
expect(element(by.css('input.sign-up-button')).isPresent()).toBeTruthy();
element(by.model('user.email')).sendKeys('foo@bar.it');
element(by.model('user.password')).sendKeys('bar');
element(by.model('user.repeatPassword')).sendKeys('bar');
element(by.cssContainingText('option', 'ITALY')).click();
element(by.css('ins.iCheck-helper')).click();
element(by.css('input.sign-up-button')).click();
$p.sleep(3000);
expect($p.getCurrentUrl()).toMatch(/dashboard/i);
});
});
Try to use browser.ignoreSynchronization = true;
and $p.sleep
because the first one makes protractor to stop waiting for angularjs and $http requests.
browser.ignoreSynchronization = true doesn't work if you need protractor to wait for elements on the page to load via Ajax.
Also Manuel you posted you had protractor version 0.24.2. Since protractor is on 1.2.0 I'm guessing that is a typo?
One possibly interesting thing I've noticed is that when phantom does crash I see org.openqa.grid.selenium.GridLauncher on my Mac menu bar at the top. I see terminal momentarily lose focus while this happens.
The occurrence of this failure seems to be completely random. But when it happens all the tests fail. And the tests usually won't pass again unless I wait a while before trying to run them.
All my tests always pass in Chrome.
@MattSavino no, my current version is 0.24.2, I'll update it. I use ignoreSynchronization with the sleep function, is the only method to make it works.
@manuelmazzuola Thanks for posting your configurations, that is really helpful. Unfortunately I'm relying on browser.addMockModule()
to stub out API calls to external services, and this doesn't work if you set browser. ignoreSynchronization = true
.
I have found that in two projects I have, phantomJS always crashes on the third test. I rewrote some of my tests to simply reset the form instead of reloading the page in between each test, and that made the tests pass in PhantomJS. However, I don't want to rewrite my tests just to work with PhantomJS, but it seems to be related to multiple browser.get()
calls.
I have been successfully running a fairly comprehensive suite of Protractor e2e tests using Chrome on OSX (Mavericks: 10.9.2).
We have a technical requirement to run these tests headlessly, so I swapped in PhantomJS instead of Chrome, and after 20 seconds (consistently), I get the following error:
Now for some more detailed information.
Here is the full error output from the
grunt
task I am running:Package versions:
Contents of
protractor.conf.js
:I have tried installing version
~1.9.7-1
of thephantomjs
package independently of the one thatprotractor
depends upon, and updating thephantomjs.binary.path
property inprotractor.conf.js
, but I get the same result.After spending far too long debugging the JS to try to isolate where the error is occurring, I know that it is falling over in
runner.js
.Specifically in
Runner.prototype.runJasmine_()
, the anonymous function passed towebdriver.promise.controlFlow().execute()
here is never executed.Can anyone help?
Let me know if you need more information.
Matt