【问题标题】:protractor without selenium server没有硒服务器的量角器
【发布时间】:2017-08-26 22:16:49
【问题描述】:

当我在命令行发出量角器命令时,配置如下:

'use strict';

// Protractor configuration
var config = {
  specs: ['test/e2e/*spec.js']
};

if (process.env.TRAVIS) {
  config.capabilities = {
    browserName: 'firefox'
  };
}

exports.config = config;

我明白了:

$ protractor
[12:22:23] I/launcher - Running 1 instances of WebDriver
[12:22:23] I/local - Starting selenium standalone server...
[12:22:24] I/local - Selenium standalone server started at http://10.0.0.242:55414/wd/hub
Started
.


1 spec, 0 failures
Finished in 8.223 seconds

[12:22:33] I/local - Shutting down selenium standalone server.
[12:22:33] I/launcher - 0 instance(s) of WebDriver still running
[12:22:33] I/launcher - chrome #01 passed

问题是启动“selenium 独立服务器”需要 5 秒以上。

两个问题 - (1) 我需要这台服务器来运行测试吗?以及(2),有没有办法在后台运行服务器而不必每次都重新启动服务器?

【问题讨论】:

    标签: angularjs node.js selenium protractor


    【解决方案1】:

    您还可以在量角器配置中使用 selenium 服务器 jar。查看下面的示例。这在使用 phantojs 时也会派上用场。

    seleniumServerJar: '../utils/selenium-server-standalone-2.53.1.jar',

    硒端口:4444,

    使用户 seleniumAddress 在配置中被注释

    【讨论】:

      【解决方案2】:

      您是否使用量角器DirectConnect 选项?如果是这样,您也可以使用独立的webdriver-manager。 Protractor 也将其用作依赖项。

      对于本地开发,我使用npm install webdriver-manager -g 将其安装为全局,然后使用webdriver-manager update 更新它并使用webdriver-manager start 启动它。然后它将在默认端口 4444 上在后台运行,运行 webdriver-manager 以查看所有选项。

      然后您不需要为每个测试/套件启动 webdriver。

      希望对你有帮助

      【讨论】:

      • 谢谢,对不起,我忘了复制我的配置,只是将它添加到问题中。这不太奏效 - DirectConnect 选项是命令行标志吗?还是配置字段?
      • 好的,我在我的配置中使用了“directConnect: true”并且它起作用了——但是,理想情况下,我可以与运行后台的 selenium webdriver 服务器通信
      • 你的配置有点小,如果你想在后台和selenium服务器对话至少需要加上config.seleniumAddress='http://localhost:4444/wd/hub';。然后它将对该地址执行所有测试。
      猜你喜欢
      • 1970-01-01
      • 2015-08-16
      • 2015-11-16
      • 2021-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      • 1970-01-01
      相关资源
      最近更新 更多