您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源功能測(cè)試工具 > Selenium
Selenium grid 使用方法
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2014/10/29 11:48:38 ] 推薦標(biāo)簽:代碼 Selenium

  代碼和selenium driver相同 只是 啟動(dòng)環(huán)境方式不同。至少啟動(dòng)一個(gè)hub 一個(gè) node 。如需要多個(gè),可以使用端口進(jìn)行區(qū)分。
java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5555
java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5556
java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5557
  代碼如下
WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
//test01: 只匹配Windows下的ie來執(zhí)行此用例,版本不限;多個(gè)版本匹配成功時(shí)優(yōu)先級(jí)暫未知
DesiredCapabilities aDesiredcap = DesiredCapabilities();
aDesiredcap.setBrowserName("internet explorer")
aDesiredcap.setVersion("")
aDesiredcap.setPlatform(Platform.WINDOWS)
WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
wd.doSomething()
//test02: 只匹配linix下的firefox的版本為22的瀏覽器執(zhí)行用例;
DesiredCapabilities aDesiredcap = DesiredCapabilities("firefox", "22", Platform.LINUX);
WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
wd.doSomething()
//test03: 只匹配MAC下的safari瀏覽器執(zhí)行,版本不限
DesiredCapabilities aDesiredcap = DesiredCapabilities.safari();
aDesiredcap.setPlatform(Platform.MAC)
WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
wd.doSomething()
//test04: 只匹配chrome瀏覽器,任意平臺(tái),任意版本
DesiredCapabilities aDesiredcap = DesiredCapabilities.chrome();
aDesiredcap.setPlatform(Platform.ANY)
WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
wd.doSomething()

軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd