2

I'm reading this Angular tutorial and in the first chapter they explained how to run unit and e2e tests. In the tutorial they use Chrome and Firefox. Since I run application on Ubuntu 14 virtual machine with no GUI I decided to use Phantomjs browser.

Eventually I was able to run unit tests with Phantom, but I have problems with e2e.

This is how protractor-conf.js looks like:

exports.config = {
allScriptsTimeout: 11000,

specs: [
'e2e/*.js'
],

  capabilities: {
    'browserName': 'phantomjs',
    'phantomjs.binary.path':'./node_modules/phantomjs/bin/phantomjs',
    'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']
  },

  chromeOnly:true,

  baseUrl: 'http://localhost:8000/',

  framework: 'jasmine',

  jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};

But when I run tests there is a following error:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
[launcher] Process exited with error code 1

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: spawn ENOENT
at errnoException (child_process.js:988:11)
at Process.ChildProcess._handle.onexit (child_process.js:779:34)
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0

Did I miss something in configuration? How to get more detailed error description in this case?

Tamara
  • 2,910
  • 6
  • 44
  • 73
  • What version of node are you using `node --version` and what version of protractor? – martin770 Jan 13 '16 at 20:51
  • Could be related: http://stackoverflow.com/questions/21072439/protractor-0-16-1-e2e-angularjs-starting-selenium-standalone-server-events. – alecxe Jan 13 '16 at 22:42
  • @martin770 Node version is v0.10.25. Protractor version is 2.5.1. – Tamara Jan 14 '16 at 14:06
  • That version of node should be compatible with that version of protractor, I've used that same configuration before but not with phantomJS. Unless you really need phantom, I would suggesting using xvfb-run for a virtual display and chrome for your browser. – martin770 Jan 14 '16 at 14:25

1 Answers1

2

This particular problem (weird error 8) can be solved by installing java:

sudo apt-get install openjdk-7-jdk

However, I still can not run tests because another issue occurred. In my case it is:

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

It looks like using phantomjs is a road paved with tortures, maybe I should try firefox with xvfb like @martin770 suggested.


UPD

This post can be helpful too if you are running in a problem with dying phantom.js https://gist.github.com/tfnico/8471223

User barzik advised to add the following command to the beforeEach:

browser.ignoreSynchronization = true; 
browser.get('/');  //or any page you are going to test 
browser.waitForAngular();
Tamara
  • 2,910
  • 6
  • 44
  • 73