Setting up PhantomJs with Protractor does not work

i'm starting my adventure with Protractor & Jasmine & PhantomJS. What I wanted to achieve is to use PhantomJS to run tests from ProtractorDemo. But I failed, and I don't know why. Where are exact steps:

I've installed protractor-demo (https://github.com/juliemr/protractor-demo)

git clone https://github.com/juliemr/protractor-demo.git
cd protractor-demo
npm install

Then I've installed phantomjs:

npm install --save-dev phantomjs

Then I've updated configuration (based on http://angular.github.io/protractor/#/browser-setup):

capabilities: {
  'browserName': 'phantomjs',

  /* 
   * Can be used to specify the phantomjs binary path.
   * This can generally be ommitted if you installed phantomjs globally.
   */
  'phantomjs.binary.path':'./node_modules/phantomjs/bin/phantomjs',

  /*
   * Command line arugments to pass to phantomjs. 
   * Can be ommitted if no arguments need to be passed. 
   * Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options
   */
  'phantomjs.cli.args':['--logfile=PATH', '--loglevel=DEBUG']
}

Full config file looks like this:

// Tests for the calculator. exports.config = {   seleniumAddress: 'http://localhost:4444/wd/hub',

  specs: [
    'spec.js'   ],

  capabilities: {
      'browserName': 'phantomjs',

      /* 
       * Can be used to specify the phantomjs binary path.
       * This can generally be ommitted if you installed phantomjs globally.
       */
      'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs',

      /*
       * Command line arugments to pass to phantomjs. 
       * Can be ommitted if no arguments need to be passed. 
       * Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options
       */
      'phantomjs.cli.args': ['--logfile=PATH', '--loglevel=DEBUG']   } };

Then I've executed commands from tutorial:

.node_modules.binwebdriver-manager update

I've started WebDriver and web server:

.node_modules.binwebdriver-manager start
npm start

The output from this command was:

Using the selenium server at http://127.0.0.1:4444/wd/hub
Server running at http://localhost:3456

And final step:

node_modules.binprotractor testconf.js

and the output form other webdriver-manager console window was:

15:23:10.181 INFO - Executing: [new session: Capabilities [{phantomjs.binary.path=./node_modules/phantomjs/bin/phantomjs, count=1, browserName=phantomjs, phantomjs.cli.args=[--logfile=PATH, --loglevel=DEBUG]}]])
15:23:10.192 INFO - Creating a new session for Capabilities [{phantomjs.binary.path=./node_modules/phantomjs/bin/phantomjs, count=1, browserName=phantomjs, phantomjs.cli.args=[--logfile=PATH, --loglevel=DEBUG]}]
15:23:10.203 INFO - executable: d:devprotractor-demo.node_modulesphantomjsbinphantomjs
15:23:10.203 INFO - port: 44410
15:23:10.203 INFO - arguments: [--logfile=PATH, --loglevel=DEBUG, --webdriver=44410, --webdriver-logfile=d:devprotractor-demophantomjsdriver.log]
15:23:10.204 INFO - environment: {}

But nothing happens. I see not result of executed tests. Is there something I'm missing? When I change the browser from phantomjs to chrome, I see test results.


In fact you don't need to run:

.node_modules.binwebdriver-manager update

nor:

.node_modules.binwebdriver-manager start

Instead you could start a ghost driver with the following command (9515 will be the port in which the driver will run) by running:

phantomjs --webdriver=9515

In addition to it you should modify your config file in order to let protractor know where the driver will be found. For your case, your config file should look like the following:

exports.config = {   
    seleniumAddress: 'http://localhost:9515',

    specs: ['spec.js'],

    capabilities: {
        'browserName': 'phantomjs',

         /* 
         * Can be used to specify the phantomjs binary path.
         * This can generally be ommitted if you installed phantomjs globally.
         */
         'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs',

         /*
         * Command line arugments to pass to phantomjs. 
         * Can be ommitted if no arguments need to be passed. 
         * Acceptable cli arugments: https://github.com/ariya/phantomjs/wiki/API-Reference#wiki-command-line-options
         */
         'phantomjs.cli.args': ['--logfile=PATH', '--loglevel=DEBUG']   
      }
};

And then you will be able to run the tests by running:

node_modules.binprotractor testconf.js
链接地址: http://www.djcxy.com/p/81972.html

上一篇: 在新的WhatsApp ver 2.11.399上添加标题(android)

下一篇: 使用量角器设置PhantomJs不起作用