Dan
Dan

Reputation: 1362

Protractor does not automatically start PhantomJS

I'm using protractor (with grunt-protractor-runner to run my E2E Angular tests), but I can't get PhantomJS to start automatically.

My protractor config looks like this:

exports.config = {
    //seleniumAddress: "http://localhost:9515",
    specs: [
        'static_src/test/spec/*.js'
    ],


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

My understanding is that with that configuration protractor will automatically spin up a PhantomJS instance (found on phantomjs.binary.path), run the tests against it, communicating directly using the WebDriver protocol (so no need for a Selenium server), and then spin down the PhantomJS instance.

Given that,

  1. Is what I've described above the expected behaviour?
  2. Is there anything I need to add to the configuration to make that happen?

Upvotes: 4

Views: 3726

Answers (1)

Andre Paap
Andre Paap

Reputation: 751

Protractor always needs a Selenium standalone server. You can start it using the webdriver-manager and referring to the address in your protract.conf.js or you can specify the location of the jar and Protractor will start it for you.

Refer the jar in your configuration, e.g.:

seleniumServerJar: 
  'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.38.0.jar'

Using this method, you don't have to worry about the selenium server starting up, but it is a little slower. So if you need to rerun your tests often it is faster to start the it as standalone, independent from Protractor.

Upvotes: 1

Related Questions