javascript 使用/不使用硒运行量角器的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30600738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference running Protractor with/without Selenium?
提问by meteor
Checking the protractor documentation, I see there is a option to run protractor without using Selenium server using directConnect: true
flag.
检查量角器文档,我看到有一个选项可以在不使用 Selenium 服务器的情况下使用directConnect: true
标志运行量角器。
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?
除了仅支持 Chrome、Firefox 之外,使用 selenium 服务器和不使用 selenium 服务器运行量角器测试有什么区别?
回答by alecxe
First of all, currently, you have 5 different built-in options/ways to connect to browser drivers:
首先,目前,您有5 种不同的内置选项/方法可以连接到浏览器驱动程序:
- specify
seleniumServerJar
to start selenium standalone server locally - specify
seleniumAddress
to connect to a running selenium server (local or remote) - set
sauceUser
andsauceKey
to connect to Sauce Labs remote selenium server - set
browserstackUser
andbrowserstackKey
to use remote Selenium Servers via BrowserStack - use
directConnect
to connect to Chrome or Firefox directly. There are additionalchromeDriver
andfirefoxPath
setting that you can use to define custom Chrome driver and Firefox application binary locations.
- 指定
seleniumServerJar
在本地启动 selenium 独立服务器 - 指定
seleniumAddress
连接到正在运行的 selenium 服务器(本地或远程) - 设置
sauceUser
并sauceKey
连接到 Sauce Labs 远程 selenium 服务器 - 通过 BrowserStack设置
browserstackUser
和browserstackKey
使用远程 Selenium 服务器 - 用于
directConnect
直接连接到 Chrome 或 Firefox。还有其他chromeDriver
和firefoxPath
设置,您可以用它来定义自定义浏览器驱动器和Firefox浏览器的应用程序二进制文件的位置。
The first 4 options basically work through a "proxy", a selenium server:
前 4 个选项基本上通过一个“代理”,一个硒服务器工作:
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.
服务器充当测试脚本(使用 WebDriver API 编写)和浏览器驱动程序(由 WebDriver 协议控制)之间的代理。服务器将命令从您的脚本转发到驱动程序,并将来自驱动程序的响应返回到您的脚本。
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 服务器而不是直接 webdriver 连接自动化浏览器的主要原因是 selenium 服务器,如果充当Selenium Grid,允许您跨多个浏览器、多个系统上的多个浏览器扩展/扩展您的测试,请参阅例如,Sauce Labs Selenium Grid。仅供参考,还有BrowserStack
service,除了其他功能外,它充当 selenium 服务器,与 Sauce Labs 类似,具有大量不同的功能/配置 - 浏览器和系统。
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.
启动 selenium 服务器(谈到选项 2)而不使用的另一个用例directConnect
是,您可能有一个特定的配置,您希望在其上运行测试。假设您有一台装有 IE 11 的 Windows 机器和装有 Firefox 35 的 Ubuntu。在这种情况下,您可以将这些机器配置为 selenium 节点,这些节点将连接到selenium 服务器/集线器。
If you are running your tests locally and your target browsers are Chrome or/and Firefox, use directConnect
, your tests would run faster.
如果您在本地运行测试并且您的目标浏览器是 Chrome 或/和 Firefox,请使用directConnect
,您的测试将运行得更快。
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.
但是,如果您在本地运行测试并需要针对 IE、Safari 或其他浏览器进行测试,则可以使用选项 1-4(通常为 1),因为这些浏览器无法在“直接连接”模式下工作。
See also related topics:
另请参阅相关主题:
回答by Priyanshu Shekhar
In simple words if directConnect
is true then it will run the tests without using selenium server. Where selenium server means a setup similar to Selenium Grid(Hub and node). Running tests via Selenium Server allows you to run tests on remote machine or on your local machine and provides an option to distribute execution load among different nodes. It is also possible to run test on multiple browsers at same time using selenium server.
简而言之,如果directConnect
为真,那么它将在不使用 selenium 服务器的情况下运行测试。其中 selenium 服务器意味着类似于Selenium Grid(集线器和节点)的设置。通过 Selenium Server 运行测试允许您在远程机器或本地机器上运行测试,并提供在不同节点之间分配执行负载的选项。也可以使用 selenium 服务器同时在多个浏览器上运行测试。
While directConnect
false will run test only on your local installation of FireFox and Chrome. It will run the test on same machine where test codebase exist.
而directConnect
false 将仅在您本地安装的 FireFox 和 Chrome 上运行测试。它将在存在测试代码库的同一台机器上运行测试。