使用量角器设置PhantomJs不起作用

我开始与量角器和茉莉花&PhantomJS的冒险。 我想要实现的是使用PhantomJS从ProtractorDemo运行测试。 但是我失败了,我不知道为什么。 确切的步骤在哪里:

我已经安装了量角器演示(https://github.com/juliemr/protractor-demo)

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

然后我安装了phantomjs:

npm install --save-dev phantomjs

然后我更新了配置(基于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']
}

完整的配置文件如下所示:

// 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']   } };

然后我执行了教程中的命令:

.node_modules.binwebdriver-manager update

我已经开始WebDriver和Web服务器:

.node_modules.binwebdriver-manager start
npm start

该命令的输出是:

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

最后一步:

node_modules.binprotractor testconf.js

其他webdriver-manager控制台窗口的输出是:

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: {}

但没有任何反应。 我看不到执行测试的结果。 有什么我失踪? 当我将浏览器从phantomjs更改为Chrome时,我会看到测试结果。


实际上你不需要运行:

.node_modules.binwebdriver-manager update

也不:

.node_modules.binwebdriver-manager start

相反,您可以通过运行以下命令(9515将成为驱动程序将运行的端口)来启动ghost驱动程序:

phantomjs --webdriver=9515

除此之外,你应该修改你的配置文件,以便让量角器知道驱动程序的位置。 对于你的情况,你的配置文件应该如下所示:

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']   
      }
};

然后你将能够运行测试:

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

上一篇: Setting up PhantomJs with Protractor does not work

下一篇: shinyapps.io and github Packages