您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Selenium grid 使用方法
作者:網絡轉載 發(fā)布時間:[ 2014/10/29 11:48:38 ] 推薦標簽:代碼 Selenium

  代碼和selenium driver相同 只是 啟動環(huán)境方式不同。至少啟動一個hub 一個 node 。如需要多個,可以使用端口進行區(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í)行此用例,版本不限;多個版本匹配成功時優(yōu)先級暫未知
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瀏覽器,任意平臺,任意版本
DesiredCapabilities aDesiredcap = DesiredCapabilities.chrome();
aDesiredcap.setPlatform(Platform.ANY)
WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
wd.doSomething()

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