qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

Selenium grid 使用方法

代码和selenium driver相同 只是 启动环境方式不同。至少启动一个hub 一个 node 。如需要多个,可以使用端口进行区分。
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来执行此用例,版本不限;多个版本匹配成功时优先级暂未知
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的浏览器执行用例;
DesiredCapabilities aDesiredcap = DesiredCapabilities("firefox", "22", Platform.LINUX);
WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
wd.doSomething()
//test03: 只匹配MAC下的safari浏览器执行,版本不限
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()

posted on 2014-10-30 11:13 顺其自然EVO 阅读(629) 评论(0)  编辑  收藏 所属分类: 测试学习专栏selenium and watir webdrivers 自动化测试学习


只有注册用户登录后才能发表评论。


网站导航:
 
<2014年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜