有/没有硒的差异运行量角器?

检查量角器文档,我看到有一个运行选项量角器不使用 Selenium 服务器使用 directConnect: true 标志.

Checking the protractor documentation, I see there is a option to run protractor without using Selenium server using directConnect: true flag.

使用 selenium 服务器和不使用 selenium 服务器运行量角器测试有什么区别,除了后者只支持 Chrome、Firefox 之外?

What is the difference between running protractor tests with a selenium server and without a selenium server other than the fact that only Chrome, Firefox are supported for the latter case?

推荐答案

首先,目前你有 5 种不同的内置选项/连接浏览器驱动程序的方式:

First of all, currently, you have 5 different built-in options/ways to connect to browser drivers:

  1. 指定 seleniumServerJar 在本地启动 selenium 独立服务器
  2. 指定 seleniumAddress 以连接到正在运行的 selenium 服务器(本地或远程)
  3. 设置 sauceUsersauceKey 以连接到 Sauce Labs 远程 selenium 服务器
  4. 设置 browserstackUserbrowserstackKey 以通过 BrowserStack 使用远程 Selenium 服务器
  5. 使用 directConnect 直接连接到 Chrome 或 Firefox.还有其他 chromeDriverfirefoxPath 设置可用于定义自定义 Chrome 驱动程序和 Firefox 应用程序二进制位置.
  1. specify seleniumServerJar to start selenium standalone server locally
  2. specify seleniumAddress to connect to a running selenium server (local or remote)
  3. set sauceUser and sauceKey to connect to Sauce Labs remote selenium server
  4. set browserstackUser and browserstackKey to use remote Selenium Servers via BrowserStack
  5. use directConnect to connect to Chrome or Firefox directly. There are additional chromeDriver and firefoxPath setting that you can use to define custom Chrome driver and Firefox application binary locations.

前 4 个选项基本上通过代理",即 selenium 服务器工作:

The first 4 options basically work through a "proxy", a selenium server:

服务器充当测试脚本之间的代理(使用WebDriver API)和浏览器驱动程序(由 WebDriver 控制协议).服务器将命令从您的脚本转发到驱动程序并将驱动程序的响应返回到您的脚本.

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,允许您跨多个浏览器、多个系统上的多个浏览器扩展/扩展您的测试,例如,请参阅 Sauce Labs Selenium Grid.仅供参考,还有 BrowserStack 服务,除了其他功能外,它还充当一个 selenium 服务器,与 Sauce Labs 类似,具有大量不同的功能/配置 - 浏览器和系统.

The main reason to automate browsers through an intermediate selenium server as opposed to direct webdriver connect is that selenium server, if acts as a 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, that, apart of other features, acts as a selenium server with, similarly to Sauce Labs, enormous amount of different capabilities/configurations - browsers and systems.

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

The other use case of starting up a selenium server (speaking about option 2) and not using directConnect is that you may have a specific configuration(s) you want your tests to run on. Say, you have a Windows machine with IE 11 on board and Ubuntu with Firefox 35. In this case, you may configure these machines as selenium nodes which would connect to a selenium server/hub.

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

If you are running your tests locally and your target browsers are Chrome or/and Firefox, use directConnect, your tests would run faster.

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

But, if you are running your tests locally and need to test against IE, Safari or other browsers, you'd go with options 1-4 (usually 1), since these browsers cannot work in "direct connect" mode.

另请参阅相关主题:

  • Selenium"有什么区别-server-standalone.jar' 和 'Selenium Client &WebDriver'?
  • selenium server"之间的区别和独立硒服务器"罐子

相关文章