問題描述
檢查量角器文檔,我看到有一個運行選項量角器不使用 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 服務器運行量角器測試有什么區(qū)別,除了后者只支持 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 種不同的內(nèi)置選項/連接瀏覽器驅(qū)動程序的方式:
First of all, currently, you have 5 different built-in options/ways to connect to browser drivers:
- 指定
seleniumServerJar
在本地啟動 selenium 獨立服務器 - 指定
seleniumAddress
以連接到正在運行的 selenium 服務器(本地或遠程) - 設置
sauceUser
和sauceKey
以連接到 Sauce Labs 遠程 selenium 服務器 - 設置
browserstackUser
和browserstackKey
以通過 BrowserStack 使用遠程 Selenium 服務器 - 使用
directConnect
直接連接到 Chrome 或 Firefox.還有其他chromeDriver
和firefoxPath
設置可用于定義自定義 Chrome 驅(qū)動程序和 Firefox 應用程序二進制位置.
- 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.
前 4 個選項基本上通過代理",即 selenium 服務器工作:
The first 4 options basically work through a "proxy", a selenium server:
服務器充當測試腳本之間的代理(使用WebDriver API)和瀏覽器驅(qū)動程序(由 WebDriver 控制協(xié)議).服務器將命令從您的腳本轉(zhuǎn)發(fā)到驅(qū)動程序并將驅(qū)動程序的響應返回到您的腳本.
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,允許您跨多個瀏覽器、多個系統(tǒng)上的多個瀏覽器擴展/擴展您的測試,例如,請參閱 Sauce Labs Selenium Grid.僅供參考,還有 BrowserStack
服務,除了其他功能外,它還充當一個 selenium 服務器,與 Sauce Labs 類似,具有大量不同的功能/配置 - 瀏覽器和系統(tǒng).
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 節(jié)點,這些節(jié)點將連接到 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.
另請參閱相關(guān)主題:
- Selenium"有什么區(qū)別-server-standalone.jar' 和 'Selenium Client &WebDriver'?
- selenium server"之間的區(qū)別和獨立硒服務器"罐子
這篇關(guān)于有/沒有硒的差異運行量角器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!