代码和selenium driver相同 只是 启动环境方式不同。至少启动一个hub 一个 node 。如需要多个,可以使用端口进行区分。

  1. java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5555
  2. java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5556
  3. java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5557
  4. 代码如下

WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);

//test01: 只匹配Windows下的ie来执行此用例,版本不限;多个版本匹配成功时优先级暂未知

  1. DesiredCapabilities aDesiredcap = DesiredCapabilities();
  2. aDesiredcap.setBrowserName("internet explorer")
  3. aDesiredcap.setVersion("")
  4. aDesiredcap.setPlatform(Platform.WINDOWS)
  5. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
  6. wd.doSomething()
  7. //test02: 只匹配linix下的firefox的版本为22的浏览器执行用例;
  8. DesiredCapabilities aDesiredcap = DesiredCapabilities("firefox", "22", Platform.LINUX);
  9. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
  10. wd.doSomething()
  11. //test03: 只匹配MAC下的safari浏览器执行,版本不限
  12. DesiredCapabilities aDesiredcap = DesiredCapabilities.safari();
  13. aDesiredcap.setPlatform(Platform.MAC)
  14. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
  15. wd.doSomething()
  16. //test04: 只匹配chrome浏览器,任意平台,任意版本
  17. DesiredCapabilities aDesiredcap = DesiredCapabilities.chrome();
  18. aDesiredcap.setPlatform(Platform.ANY)
  19. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);
  20. wd.doSomething()

selenium grid 使用方法的更多相关文章

  1. 搭建selenium grid简单配置

    1.使用selenium提供的服务端独立jar包 :服务端.客户端都是运行于java7环境. 2.启动hub: hub配置文件如下: Java -jar selenium-server-standal ...

  2. Robot Framework + Selenium2Library环境下,结合Selenium Grid实施分布式自动化测试

    最近一段时间,公司在推行自动化测试流程,本人有幸参与了自定义通用控件的关键字封装和脚本辅助编写.数据驱动管理.测试用例执行管理等一系列工具软件的研发工作,积累了一些经验,在此与大家做一下分享,也算是做 ...

  3. Selenium Grid跨浏览器-兼容性测试

    Selenium Grid跨浏览器-兼容性测试 这里有两台机子,打算这样演示: 一台机子启动一个作为主点节的hub 和 一个作为次节点的hub(系统windows 浏览器为ie) ip为:192.16 ...

  4. 转:Selenium Grid深入学习

    应网友要求写一个用Selenium Grid控制多系统多浏览器并行执行test case的例子. 因为我这里有两台机子,我打算这样演示: 一台机子启动一个作为主点节的hub 和 一个作为次节点的hub ...

  5. Selenium Grid分布式测试入门详解

    本文对Selenium Grid进行了完整的介绍,从环境准备到使用Selenium Grid进行一次完整的多节点分布式测试. 运行环境为Windows 10,Selenium版本为 3.5.0,Chr ...

  6. Selenium Grid和IE /Firefox各种填坑

    使用selenium grid的步骤 1.确保hub和node都安装并且配置好了java jdk. 2.在hub上运行以下命令. java -jar C:\Software\selenium\sele ...

  7. 配置selenium grid

    本文对Selenium Grid进行了完整的介绍,从环境准备到使用Selenium Grid进行一次完整的多节点分布式测试. 运行环境为Windows 10,Selenium版本为 3.5.0,Chr ...

  8. .NET自动化测试工具:Selenium Grid

    在生产环境,QA会同时跑几十个上百个的test case.如果用单机串行的话,是一件非常耗时的事情,估计比手点快不了多少.使用并行方案的话,有两种方法,一个是自己写并行框架,一个是用现成的Seleni ...

  9. [Selenium] Grid 介绍

    Selenium Grid 支持分布式测试,使测试人员可在分布式环境中进行测试 一般而言,在面临以下情况时可考虑使用Selenium Grid : 1.测试多个浏览器或单个浏览器多个版本,或测试不同操 ...

随机推荐

  1. C. The Fair Nut and String 递推分段形dp

    C. The Fair Nut and String 递推分段形dp 题意 给出一个字符串选择一个序列\({p_1,p_2...p_k}\)使得 对于任意一个\(p_i\) , \(s[p_i]==a ...

  2. oracle wm_concat函数 列转行 分组函数

    (1)select mark, wm_concat(status) from DISSENT_INFO t GROUP BY mark; 查出来的数据 mark     status 222      ...

  3. Lambda 快速改造

    对于只有一个参数的接口类,可以使用e->{}  idea会给出快速提示 先写正常的表达式 将虚线处直接删掉, 在原来的方法参数和左大括号之间加上 -> 改造后比原来少了几行, 对于熟手阅读 ...

  4. vue(3)IDE

    使用vscode,下载:https://code.visualstudio.com/Download 1.安装vscode 2.安装插件 方式一:https://marketplace.visuals ...

  5. Linux下Java环境安装配置记录

    下载jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 两种安装方式: 第一 ...

  6. vue父子组件通信(prop)

    先定义子组件,注册prop接收父组件传递的值 <template> <div> <div>{{message}}(子组件)</div> </div ...

  7. Spring MVC自定义错误页面

    在web.xml中添加: <error-page(其他属性404...省略咯)> <location>/error</location> </error-pa ...

  8. sqlserver 2012 部署详解

    01,下载 官网下载: https://www.microsoft.com/zh-cn/download/details.aspx?id=29066 02,安装 检查系统环境配置 成功了就继续,其他的 ...

  9. C++学习之构造函数和析构函数及指针

    C++的构造函数在创建对象时调用,分配内存空间,多少个对象(对象数组)就调用几次构造函数:析构函数在调用结束时调用(可以添加一些最后的处理)以释放内存给其它来用.对于同类型同生命期的对象,先创建的对象 ...

  10. Barty's Computer 字典树

    https://nanti.jisuanke.com/t/17122 Barty have a computer, it can do these two things. Add a new stri ...