差异 运行 量角器 with/without 硒?

Difference running Protractor with/without Selenium?

检查量角器 documentation,我发现有一个 运行 量角器选项,无需使用使用 directConnect: true 标志的 Selenium 服务器。

使用 selenium 服务器和不使用 selenium 服务器的 运行ning 量角器测试之间有什么区别,除了后一种情况仅支持 Chrome,Firefox 之外?

简单来说,如果 directConnect 为真,那么它将 运行 测试而不使用 selenium 服务器。其中 selenium 服务器表示类似于 Selenium Grid(集线器和节点)的设置。 运行 通过 Selenium 服务器进行的测试允许您 运行 在远程计算机或本地计算机上进行测试,并提供在不同节点之间分配执行负载的选项。也可以 运行 使用 selenium 服务器同时在多个浏览器上进行测试。

虽然 directConnect false 将 运行 仅在您本地安装的 FireFox 和 Chrome 上进行测试。它将 运行 在存在测试代码库的同一台机器上进行测试。

首先,目前,您有 5 different built-in options/ways to connect to browser drivers:

  1. 指定seleniumServerJar在本地启动selenium独立服务器
  2. 指定 seleniumAddress 连接到 运行ning selenium 服务器(本地或远程)
  3. 设置 sauceUsersauceKey 以连接到 Sauce Labs 远程 selenium 服务器
  4. 设置browserstackUserbrowserstackKey通过BrowserStack使用远程Selenium服务器
  5. 使用directConnect直接连接到Chrome或Firefox。还有其他 chromeDriverfirefoxPath 设置可用于定义自定义 Chrome 驱动程序和 Firefox 应用程序二进制位置。

前 4 个选项基本上通过 "proxy"、selenium 服务器工作:

The server acts as proxy between your test script (written with the WebDriver API) and the browser driver (controlled by the WebDriver protocols). The server forwards commands from your script to the driver and returns responses from the driver to your script.

通过中间 selenium 服务器自动化浏览器而不是直接连接 webdriver 的主要原因是 selenium 服务器,如果充当 Selenium Grid, allows you to expand/scale your tests across multiple browsers, multiple browsers on multiple systems, see, for instance, Sauce Labs Selenium Grid. FYI, there is also BrowserStack service,除了其他功能外,还充当 selenium 服务器,类似于 Sauce Labs,大量不同的 capabilities/configurations - 浏览器和系统。

启动 selenium 服务器(谈到选项 2)而不使用 directConnect 的另一个用例是您可能有一个特定的配置,您希望测试 运行在。比如说,你有一台装有 IE 11 的 Windows 机器和装有 Firefox 35 的 Ubuntu 机器。在这种情况下,你可以将这些机器配置为连接到 selenium server/hub 的 selenium 节点。

如果您 运行 在本地进行测试并且您的目标浏览器是 Chrome or/and Firefox,请使用 directConnect,您的测试会 运行 更快.

但是,如果您 运行 在本地进行测试并且需要针对 IE、Safari 或其他浏览器进行测试,您会选择选项 1-4(通常是 1),因为这些浏览器无法工作在 "direct connect" 模式下。

另见相关主题:

  • What are the differences between 'Selenium-server-standalone.jar' and 'Selenium Client & WebDriver'?
  • Difference between "selenium server" and "selenium server standalone" jars