Selenium Grid分布式测试入门详解
1. Selenium Grid简介
2. Selenium Grid结构

3. 环境准备
3.1 JDK环境
3.2 selenium-server-standalone下载

3.3 webdriver下载
3.3.1 IE

3.3.2 Chrome
3.3.3 Firefox

driver下载完成解压后,分别拷贝IEDriverServer.exe,geckodriver.exe,chromedriver.exe至Python安装路径(如C:\Python27\)下即可
4. Selenium Grid启动
4.1 启动hub
java -jar selenium-server-standalone-3.5..jar -role hub

4.2 启动node
java -jar selenium-server-standalone-3.5..jar -role node -port -hub http://localhost:4444/grid/register

同理我们另外启动两个 node(使用端口号分别为5556/5557):
java -jar selenium-server-standalone-3.5..jar -role node -port -hub http://localhost:4444/grid/register
java -jar selenium-server-standalone-3.5..jar -role node -port -hub http://localhost:4444/grid/register

4.3 更好的启动方法 — bat脚本
cd /d D:\grid
start java -jar selenium-server-standalone-3.5..jar -role hub
start java -jar selenium-server-standalone-3.5..jar -role node -port -hub http://localhost:4444/grid/register
start java -jar selenium-server-standalone-3.5..jar -role node -port -hub http://localhost:4444/grid/register
start java -jar selenium-server-standalone-3.5..jar -role node -port -hub http://localhost:4444/grid/register
4.4 更多选项
d:\grid>java -jar selenium-server-standalone-3.5..jar --help
Usage: <main class> [options]
Options:
--version, -version
Displays the version and exits.
Default: false
-browserTimeout
<Integer> in seconds : number of seconds a browser session is allowed to
hang while a WebDriver command is running (example: driver.get(url)). If the
timeout is reached while a WebDriver command is still processing, the session
will quit. Minimum value is . An unspecified, zero, or negative value means
wait indefinitely.
Default:
-debug
<Boolean> : enables LogLevel.FINE.
Default: false
-enablePassThrough
<Boolean>: Whether or not to use the experimental passthrough mode.
Defaults to true.
Default: true
-jettyThreads, -jettyMaxThreads
<Integer> : max number of threads for Jetty. An unspecified, zero, or
negative value means the Jetty default value () will be used.
-log
<String> filename : the filename to use for logging. If omitted, will log
to STDOUT
-port
<Integer> : the port number the server will use.
Default:
-role
<String> options are [hub], [node], or [standalone].
Default: standalone
-timeout, -sessionTimeout
<Integer> in seconds : Specifies the timeout before the server
automatically kills a session that hasn't had any activity in the last X seconds. The
test slot will then be released for another test to use. This is typically
used to take care of client crashes. For grid hub/node roles, cleanUpCycle
must also be set.
Default:
5. Selenium Grid 分布式测试脚本
# coding:utf- from selenium.webdriver import Remote
import time # 定义node_hub与浏览器对应关系
nodes = {
'http://127.0.0.1:5555/wd/hub': 'chrome',
'http://127.0.0.1:5556/wd/hub': 'internet explorer',
'http://127.0.0.1:5557/wd/hub': 'firefox'
} # 通过不同的浏览器执行测试脚本
for host, browser in nodes.items():
print(host, browser)
# 调用remote方法
driver = Remote(command_executor=host,
desired_capabilities={'platform': 'ANY', 'browserName': browser, 'version': '', 'javascriptEnabled': True}) # 打开百度首页并搜索词语,最后判断搜索跳转页面标题是否含有搜索词
wd = 'lovesoo'
driver.get('https://www.baidu.com')
driver.find_element_by_id("kw").send_keys(wd)
driver.find_element_by_id("su").click()
time.sleep()
assert wd in driver.title, '{0} not in {1}'.format(wd, driver.title.encode('utf-8'))
driver.quit()
('http://127.0.0.1:5555/wd/hub', 'chrome')
('http://127.0.0.1:5557/wd/hub', 'firefox')
('http://127.0.0.1:5556/wd/hub', 'internet explorer')
6. 常见问题

Selenium Grid分布式测试入门详解的更多相关文章
- Selenium Grid分布式测试环境搭建
Selenium Grid简介 Selenium Grid实际上是基于Selenium RC的,而所谓的分布式结构就是由一个hub节点和若干个node代理节点组成.Hub用来管理各个代理节点的注册信息 ...
- selenium之多线程启动grid分布式测试框架封装(四)
九.工具类,启动所有远程服务的浏览器 在utils包中创建java类:LaunchAllRemoteBrowsers package com.lingfeng.utils; import java.n ...
- Redis快速入门详解
Redis入门详解 Redis简介 Redis安装 Redis配置 Redis数据类型 Redis功能 持久化 主从复制 事务支持 发布订阅 管道 虚拟内存 Redis性能 Redis部署 Redis ...
- SQL注入攻防入门详解
=============安全性篇目录============== 本文转载 毕业开始从事winfrm到今年转到 web ,在码农届已经足足混了快接近3年了,但是对安全方面的知识依旧薄弱,事实上是没机 ...
- SQL注入攻防入门详解(2)
SQL注入攻防入门详解 =============安全性篇目录============== 毕业开始从事winfrm到今年转到 web ,在码农届已经足足混了快接近3年了,但是对安全方面的知识依旧薄弱 ...
- Quartz 入门详解
Quartz是OpenSymphony开源组织在Job scheduling领域又一个开源项目,它可以与J2EE与J2SE应用程序相结合也可以单独使用.Quartz可以用来创建简单或为运行十个,百个, ...
- [转]SQL注入攻防入门详解
原文地址:http://www.cnblogs.com/heyuquan/archive/2012/10/31/2748577.html =============安全性篇目录============ ...
- 转:JAVAWEB开发之权限管理(二)——shiro入门详解以及使用方法、shiro认证与shiro授权
原文地址:JAVAWEB开发之权限管理(二)——shiro入门详解以及使用方法.shiro认证与shiro授权 以下是部分内容,具体见原文. shiro介绍 什么是shiro shiro是Apache ...
- 【转载】SQL注入攻防入门详解
滴答…滴答…的雨,欢迎大家光临我的博客. 学习是快乐的,教育是枯燥的. 博客园 首页 博问 闪存 联系 订阅 管理 随笔-58 评论-2028 文章-5 trackbacks-0 站长 ...
随机推荐
- oracle 删除外键约束 禁用约束 启用约束
oracle 删除外键约束 禁用约束 启用约束 执行以下sql生成的语句即可 删除所有外键约束 Sql代码 select 'alter table '||table_name||' drop con ...
- activiti07- Task
任务 用户任务: 用户任务,用来对那些需要人参与完成的工作进行建模.当流程执行到这样的用户任务时,会在被分配到该任务的用户或用户组的任务列表中创建新的任务. 用户任务中可以包含描述.事实上,任何BPM ...
- Three.js与webVR
WebVR如此近 - three.js的WebVR示例程序解析 关于WebVR 最近VR的发展十分吸引人们的眼球,很多同学应该也心痒痒的想体验VR设备,然而现在的专业硬件价格还比较高,入手一个估计就要 ...
- JS中基本的一些兼容问题 可能解释的不会太清楚
做兼容注意: 一如果两个都是属性,用逻辑||做兼容 二如果有一个是方法 用三目运算符做兼容 三多个属性或方法封装函数做兼容 一:谷歌浏览器和火狐浏览器鼠标滚动条兼容 1.document.docume ...
- http://codeforces.com/contest/349
A. Cinema Line time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- python采用 多进程/多线程/协程 写爬虫以及性能对比,牛逼的分分钟就将一个网站爬下来!
首先我们来了解下python中的进程,线程以及协程! 从计算机硬件角度: 计算机的核心是CPU,承担了所有的计算任务.一个CPU,在一个时间切片里只能运行一个程序. 从操作系统的角度: 进程和线程,都 ...
- Detect Capital
Given a word, you need to judge whether the usage of capitals in it is right or not. We define the u ...
- 聊聊Java语言中的单例
package com.xinke.mybatis.test; public class TestSingleton { private static TestSingleton ts = null; ...
- Python实战之dict简单练习
['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__forma ...
- Win CE 6.0 获取手持机GPS定位2----示例代码 (C#)
一.须知 1.手持机(PDA)必须有GPS模块,才能通过代码使用串口通信获取GPS相关信息 2.要清楚自己手持机(PDA)固定的GPS通信串口号,如我们公司的手持机获取GPS信息的串口为COM4 3. ...