学习selenium grid记录
1、找两台Windows系统,一个是A,作为Hub;一个是B,作为Node;
2、在A、B两台电脑分别下载selenium-server-standalone-2.48.0.jar,并放到指定目录
3、先设置Hub,打开A电脑的cmd,cd进入该目录

4、并执行命令:java -jar selenium-server-standalone-.jar -2.48.0role hub ,执行-role hub 意思是将server之行为hub主服务器,可以集中控制Node,命令行窗口出现以下i,192.168.1.2是本机IP,4444是grid默认端口

5、在浏览器输入 本机的IP 端口,打开grid,如:http://192.168.1.2:4444/grid/console,出现下图,代表启动成功,在B电脑的浏览器,输入A的IP端口访问grid成功

6、在B电脑也打开cmd窗口,进入selenium-server-standalone-2.48.0.jar 的目录,执行命令:java -jar selenium-server-standalone-2.48.0.jar -role webdriver -hub http://192.168.1.2:4444/grid/register -port 6655 ,设置B为node节点,端口号随便写一个,比如6666,讲该节点注册到主服务器A,执行命令后如下显示:

在A电脑的浏览器刷新grid地址,会出现Node的IP及配置信息

7、相关代码如下:
public static String nodeUrl = "http://192.168.1.5:6655/wd/hub";
@BeforeMethod
public void beforeMethod() throws MalformedURLException{
DesiredCapabilities capability = DesiredCapabilities.firefox();//设定远程方法使用Firefox浏览器
capability.setBrowserName("firefox");//设置node的浏览器为Firefox
//设置node使用的操作系统为WINDOWS,设置成Win10报:org.openqa.selenium.WebDriverException: No enum constant org.openqa.selenium.Platform.WIN10,没去找具体原因,有空再分析
capability.setPlatform(Platform.WINDOWS);
//设置node的Firefox的路径,如果用System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");不起作用,设置不了远程服务器的firefox路径
capability.setCapability("firefox_binary", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");//不设置时,报错selenium grid: Cannot find firefox binary in PATH.
driver = new RemoteWebDriver(new URL(nodeUrl), capability);//启动node的driver
driver.get("http://www.baidu.com/");
}
8、大概是这样,还有2个问题待解决
1)用selenium-server-standalone-3.9.1.jar,执行脚本会报Driver info: driver.version: unknown,可能用高版本的grid需要再配置其他配置
2)打开的火狐浏览器,总是默认打开火狐起始页,待解决
参考文档:https://www.cnblogs.com/zhangyachaun/p/4409480.html ,写的很全,对我帮助很大,分享给大家
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
远程IE浏览器设置:
1、在B服务器进行Hub节点注册使用如下命令
java -jar selenium-server-standalone-2.48.0.jar -role webdriver -hub http://192.168.1.2:4444/grid/register -Dwebdriver.ie.dirver="C:\IEDriverServer.exe" -port 6655 -maxSession 5 -browser browserName="internet explorer",maxInstances=5
2、设置远程方法:
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();//设定远程方法使用internetExplorer浏览器
capability.setBrowserName("internetExplorer");//设置node的浏览器为internetExplorer
远程Chrome设置
1、在B服务器进行Hub节点注册使用如下命令
java -jar selenium-server-standalone-2.48.0.jar -role webdriver -hub http://192.168.1.2:4444/grid/register -Dwebdriver.chrome.dirver="C:\chromedriver.exe" -port 6655 -maxSession 5 -browser browserName="chrome",maxInstances=5
2、设置远程方法:
DesiredCapabilities capability = DesiredCapabilities.chrome();//设定远程方法使用chrome浏览器
capability.setBrowserName("chrome");//设置node的浏览器为chrome
学习selenium grid记录的更多相关文章
- Selenium Grid 学习笔记
Selenium Grid 学习笔记http://www.docin.com/p-765680298.html
- 转:Selenium Grid深入学习
应网友要求写一个用Selenium Grid控制多系统多浏览器并行执行test case的例子. 因为我这里有两台机子,我打算这样演示: 一台机子启动一个作为主点节的hub 和 一个作为次节点的hub ...
- 新人学习selenium哪些资源比较有帮助?
为什么学习selenium? selenium现在基本上成了页面自动化测试的标配,具体理由我在selenium 3.0发布这篇文章里已经说明过了.当一个东西成为标准以后,那么它的能量和潜力都是巨大的. ...
- Selenium-IDE,Selenium-RC ,Selenium grid以及 Selenium-Core
Selenium-IDE,Selenium-RC ,Selenium grid 以及 Selenium-Core Selenium 是一种 Web 应用的自动测试工具,通过模拟用户对 Web 页面的各 ...
- selenium grid 环境搭建
一.selenium grid简介 selenium grid可以同时在不同机器上测试不同浏览器,包含一个hub和多个node.node会发送配置信息到hub,hub记录并跟踪每一个node的配置信息 ...
- 搭建selenium grid简单配置
1.使用selenium提供的服务端独立jar包 :服务端.客户端都是运行于java7环境. 2.启动hub: hub配置文件如下: Java -jar selenium-server-standal ...
- Robot Framework + Selenium2Library环境下,结合Selenium Grid实施分布式自动化测试
最近一段时间,公司在推行自动化测试流程,本人有幸参与了自定义通用控件的关键字封装和脚本辅助编写.数据驱动管理.测试用例执行管理等一系列工具软件的研发工作,积累了一些经验,在此与大家做一下分享,也算是做 ...
- Java学习-007-Log4J 日志记录配置文件详解及实例源代码
此文主要讲述在初学 Java 时,常用的 Log4J 日志记录配置文件详解及实例源代码整理.希望能对初学 Java 编程的亲们有所帮助.若有不足之处,敬请大神指正,不胜感激!源代码测试通过日期为:20 ...
- Selenium Grid 运行报错 Exception thrown in Navigator.Start first time ->Error forwarding the new session Empty pool of VM for setup Capabilities
Selenium Grid 运行报错 : Exception thrown in Navigator.Start first time ->Error forwarding the new se ...
随机推荐
- 编写mapreduce的程序的套路
https://blog.csdn.net/qq_42881421/article/details/83543926 给出下面6个经典案例: http://www.cnblogs.com/xia520 ...
- 报错——userdel: user hhh is currently used by process 9218
报错 userdel: user hhh is currently used by process 9218 [root@centos71 ~]# useradd hhh [root@centos71 ...
- bootstrap 点击模态框上的提交按钮后,模态框不能关闭的解决办法
项目问题如下图, 点击确定后,模态框没反应,按理,点击删除按钮时,弹出确认删除的模态框,点击确定后,使用ajax请求服务器,把数据库中对应的数据进行删除,根据服务器 servlet返回的状态值(del ...
- JS中的getter和setter
对象有两种属性:(1)数据属性,就是我们经常使用的属性(2)访问器属性,也称存取器属性 存取器属性就是一组获取和设置值的函数.getter负责获取值,它不带任何参数.setter负责设置值,在它的函数 ...
- 10.14 socket 网络编程
简单的例子 socket客户端 import socket client = socket.socket() #声明socket类型,同时生成socket连接对象 client.connect(('l ...
- HashMap的底层原理 cr:csdn:zhangshixi
1. HashMap概述: HashMap是基于哈希表的Map接口的非同步实现.此实现提供所有可选的映射操作,并允许使用null值和null键.此类不保证映射的顺序,特别是它不保证该顺序恒久不变 ...
- window 任务管理器
用的是win10 系统,一般window都差不多. 1.查看进程: 2.查看端口:性能 --> 打开资源资源监视器 --> 网络 --> 侦听端口 3.查看磁盘活动(查看文件被哪个进 ...
- SQL 关键字的使用顺序
1.查询中用到的关键词主要包含六个,并且他们的顺序依次为 select --> from --> where --> group by --> having --> or ...
- Menu [D3D9 Source]
源代码下载地址:http://download.csdn.net/detail/wd844125365_/8008779
- CPUID
http://en.wikipedia.org/wiki/CPUID CPUID From Wikipedia, the free encyclopedia The CPUID opcode i ...