selenium Grid配置
selenium是一个用于UI自动化测试的工具。selenium grid是selenium家族中的三大组件的一员。selenium grid有两个版本,grid1和grid2,。目前grid1已经基本被废弃了。grid2的出版要晚于selenium2,所以grid2支持selenium2的所有的功能。
1.下载selenium-server-standalone-2.53.1.jar
下载地址:http://selenium-release.storage.googleapis.com/index.html
下载驱动 InternetExplorerDriver,ChromeDriver
2.启动hub
使用快捷键WIN+R打开运行对话框cmd,进入命令窗口
进入selenium-server-standalone-2.53.1.jar包的位置,如E:\selenium
启动hub命令:java -jar selenium-server-standalone-2.53.1.jar -role hub -maxSession 10 -port 4444
参数解析 -role hub表示启动运行hub;
-port是设置端口号,
hub的默认端口是4444,这里使用的是默认的端口,也可以自己配置;
-maxSession为最大会话请求,这个参数主要要用并发执行测试用例,默认是1,建议设置10及以上。
3.验证是否启动成功
本地浏览器访问: http://localhost:4444/grid/console

4.添加node节点1
java -jar selenium-server-standalone-2.53.1.jar -role node -port 5555 -hub http://hub集线器的ip:4444/grid/register -Dwebdriver.chrome.driver=chromedriver.exe -maxSession 5 -browser browserName=chrome,seleniumProtocol=WebDriver,maxInstances=5,platform=WINDOWS,version=75.0.3770.90
参数解析:
-role node:表示启动的是node节点
-port 5555:指定node节点端口
-hub http://hub集线器的ip:4444/grid/register:表示hub机地址
-maxSession 5:node节点最大会话请求
-browser browserName=chrome,seleniumProtocol=WebDriver,maxInstances=5,platform=WINDOWS,version=75.0.3770.90
设置浏览器参数:browserName浏览器名字,如chrome、firefox、ie
maxInstances表示最大实例,可以理解为最多可运行的浏览器数,这个值不能大于前面maxSession的值,否则可能会出错
platform表示操作系统
version表示浏览器版本
5.添加node节点2
java -jar selenium-server-standalone-2.53.1.jar -role node -port 6666 -hub http:///hub集线器的ip:4444/grid/register -Dwebdriver.ie.driver=IEDriverServer.exe -browser browserName=IE
6.查看是否添加成功
再次刷新一下http://localhost:4444/grid/console的访问会发现node节点已经显示


浙公网安备 33010602011771号