鍍金池/ 教程/ Python/ Selenium網(wǎng)格
log4j日志
Selenium IDE測試創(chuàng)建
Selenium - IDE模式匹配
Selenium教程
多瀏覽器測試
Selenium IDE下載
Selenium用戶擴展
鍵盤操作
捕捉屏幕截圖
Selenium網(wǎng)格
Selenium TestNG
Selenium定位器
查找所有鏈接
Selenium測試設(shè)計技術(shù)
鼠標(biāo)操作
下拉框交互
Selenium IDE驗證點
Selenium IDE- 不同的瀏覽器
Selenium RC
多選擇操作
復(fù)選框交互
單選按鈕互動
捕捉視頻
拖放
Selenium IDE 測試
Synchronization 同步
異常處理
Selenium 環(huán)境安裝設(shè)置
Selenium概述
用戶交互
Selenium Webdriver
Selenium IDE
Selenium頁面對象模型
Selenium IDE 工具特點
使用Excel數(shù)據(jù)驅(qū)動
Selenium - Selenese命令

Selenium網(wǎng)格

Selenium網(wǎng)格

Selenium網(wǎng)格是分布在多個物理或虛擬機測試,使我們能夠并行(同時)執(zhí)行腳本,導(dǎo)致執(zhí)行所需的運行測試時間的工具。這給予我們快速而準(zhǔn)確的反饋大大加快了跨瀏覽器和跨平臺的測試。

Selenium網(wǎng)格使我們能夠執(zhí)行并行的webdriver或Selenium的遠(yuǎn)程控制的測試,它使用相同的代碼的基礎(chǔ)上,因此,代碼不必存在它們執(zhí)行系統(tǒng)上的多個實例。Selenium服務(wù)器的獨立軟件包包括集線器,webdriver,和Selenium RC網(wǎng)格執(zhí)行腳本。

Selenium 網(wǎng)格具有樞紐和節(jié)點

  • Hub - 集線器也可以理解為服務(wù)器充當(dāng)中心點所在的測試將被觸發(fā)。Selenium網(wǎng)格只有一個集線器,它是一臺機器上啟動一次。

  • Node - 節(jié)點是Selenium實例附連到將執(zhí)行測試的集線器??梢源嬖谠谄渲锌梢允侨魏尾僮飨到y(tǒng),并且可以包含任何所支持的瀏覽器Selenium網(wǎng)格的一個或多個節(jié)點。

體系結(jié)構(gòu)

Selenium 網(wǎng)格的體系結(jié)構(gòu)是用簡單的流程圖來解釋。

selenium_ide_121

使用網(wǎng)格工作

為了與網(wǎng)格工作,我們需要確保遵循一定的協(xié)議。下面是所涉及的主要步驟,了解他們的每一個細(xì)節(jié)。

  • Configuring Hub

  • Configuring Nodes

  • Develop Script

  • XML Preperation

  • Test Execution

  • Result Analysis

配置Hub

步驟1:從http://docs.seleniumhq.org/download/下載最新的Selenium服務(wù)器獨立JAR文件。通過點擊版本如下所示下載。

selenium_ide_45

第2步:使用以下命令啟動Selenium服務(wù)器啟動的集線器。現(xiàn)在,我們將使用端口“4444”啟動集線器。

注:請確保端口#4444運行沒有被其他應(yīng)用程序占用。

java -jar selenium-server-standalone-2.25.0.jar -port 4444 -role hub -nodeTimeout 1000
selenium_ide_122

第3步:現(xiàn)在打開瀏覽器,然后從集線器導(dǎo)航到http//localhost:4444 (其中已執(zhí)行的系統(tǒng)步驟#2)。

selenium_ide_123

第4步:現(xiàn)在點擊“console”鏈接,然后單擊“view config”。將顯示hub的配置。截至目前,我們還沒有得到任何節(jié)點,因此我們將無法看到細(xì)節(jié)。

selenium_ide_124

配置節(jié)點

第1步:登錄到節(jié)點(想執(zhí)行腳本),然后替換文件夾中的“selenium-server-standalone-2.42.2”。我們需要發(fā)起節(jié)點時指向selenium-server-standalone 的JAR。

第2步:使用以下命令啟動Firefox節(jié)點。

java -jar D:JARselenium-server-standalone-2.42.2.jar -role node -hub http://10.30.217.157:4444/grid/register -browser browserName=firefox -port 5555

Where,
D:JARselenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine)
http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub
browserName = firefox (Parameter to specify the Browser name on Nodes)
5555 = Port on which Firefox Node would be up and running.
selenium_ide_125

第3步:執(zhí)行該命令后,現(xiàn)在回過頭來集線器。導(dǎo)航到URL - http://10.30.217.157:4444和集線器現(xiàn)在會顯示在所連接的節(jié)點。

selenium_ide_126

第4步:現(xiàn)在,讓我們啟動Internet Explorer節(jié)點。用于啟動IE瀏覽器節(jié)點,我們需要確保我們有下載的節(jié)點機上的Internet Explorer驅(qū)動程序。

第5步:要下載Internet Explorer的驅(qū)動程序,根據(jù)您的操作系統(tǒng)的架構(gòu)導(dǎo)航到http://docs.seleniumhq.org/download/并下載。下載后解壓縮exe文件,并將其放置其中有被稱為同時推出IE瀏覽器節(jié)點上的一個文件夾。

selenium_ide_131

第6步:使用以下命令啟動IE瀏覽器。

C:>java -Dwebdriver.ie.driver=D:IEDriverServer.exe -jar D:JARselenium-server-standalone-2.42.2.jar -role webdriver -hub http://10.30.217.157:4444/grid/register -browser browserName=ie,platform=WINDOWS -port 5558

Where,
D:IEDriverServer.exe = The location of the downloaded the IE Driver(on the Node Machine)
D:JARselenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine)
http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub
browserName = ie (Parameter to specify the Browser name on Nodes)
5558 = Port on which IE Node would be up and running.
selenium_ide_127

第7步:執(zhí)行該命令后,現(xiàn)在再回到集線器。導(dǎo)航到URL- http://10.30.217.157:4444 集線器現(xiàn)在會顯示所連接的IE瀏覽器節(jié)點。

selenium_ide_128

第8步:現(xiàn)在我們啟動Chrome節(jié)點。用于啟動瀏覽器節(jié)點,我們需要確保我們有下載的節(jié)點機上瀏覽器的驅(qū)動程序。

第9步:下載Chrome瀏覽器驅(qū)動程序,導(dǎo)航到http://docs.seleniumhq.org/download/并導(dǎo)航到第三方瀏覽器驅(qū)動區(qū)域,然后單擊版本號“2.10”,如下圖所示。

selenium_ide_132

第10步:下載基于操作系統(tǒng)的類型的驅(qū)動程序。我們會執(zhí)行它在Windows環(huán)境,因此我們將下載的Chrome瀏覽器的Windows驅(qū)動程序。下載后解壓縮exe文件,并將它具有同時啟動Chrome節(jié)點被稱為一個文件夾。

selenium_ide_133

第11步:使用以下命令啟動chrome 。

C:>java -Dwebdriver.chrome.driver=D:chromedriver.exe -jar D:JARselenium-server-standalone-2.42.2.jar -role webdriver -hub  http://10.30.217.157:4444/grid/register -browser browserName=chrome,platform=WINDOWS -port 5557

Where,
D:chromedriver.exe = The location of the downloaded the chrome Driver(on the Node Machine)
D:JARselenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine)
http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub
browserName = chrome (Parameter to specify the Browser name on Nodes)
5557 = Port on which chrome Node would be up and running.
selenium_ide_129

第7步:執(zhí)行該命令后,現(xiàn)在再回集線器。導(dǎo)航到URL- http://10.30.217.157:4444 集線器現(xiàn)在會顯示連接到chrome 節(jié)點。

selenium_ide_130

開發(fā)腳本