Selenium Grid 简易安装--(selenium-server-standalone-*.jar)
2013-12-14 23:24
267 查看
Selenium Grid
Selenium Grid允许同时并行地、在不同的环境上运行多个测试任务。这里主要演示一下怎么使用Selenium Grid。准备:
1、需要两台机子
2、两台机子分别安装好JDK环境
3、两台机子需要从 http://code.google.com/p/selenium/downloads/list下载selenium-server-standalone-*.jar包
开始:
Grid需要一台机子做为主节点,然后其它机子做为子节点连接到这个主节点上来。所以首先要启动主节点。
启动主节点:
选一台机子做为主节点。打开命令行,cd至selenium-server-standalone-*.jar包的目录下,然后用下面的命令启动主节点服务:
java -jar selenium-server-standalone-2.24.1.jar -role hub
默认启动默认端口为4444。如果要改这个端口,可以再上面的命令后面加上 -port XXXX。启动完后,你可以用浏览 器 打开 http://localhost:4444/grid/console 这个网址查看主节点的状态。
启动完主节点之后,要做的就是启动子节点。
启动子节点:
先另一台机子做为子节点。同样打开命令行,cd至selenium-server-standalone-*.jar包的目录下,然后用下面的命令启动次节点服务:
java -jar selenium-server-standalone-2.24.1.jar -role node -hubhttp://192.168.4.124:4444/grid/register
其中192.168.4.124为主节点机子的ip地址,可以使用ipconfig命令在命令行查看得到。上面命令默认启动5555端口,可使用-port 更改。
启动完成连接到主节点后,可以在主节点机子上 ,http://localhost:4444/grid/console网址查看到这个子节点状态。使用同样的方法,可以链接其它的子节点。
运行一个简单的例子:
上面已经把grid弄成功了,现在我们用Grid来运行一个很简单的例子。代码如下:
import java.net.MalformedURLException; import java.net.URL; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; public class GridTest { /** * @throws MalformedURLException */ public static void main(String[] args) throws MalformedURLException { DesiredCapabilities test = DesiredCapabilities.firefox(); WebDriver dr = new RemoteWebDriver(new URL("http://192.168.4.137:5555/wd/hub"),test); dr.get("http://www.baidu.com"); } }
在主节点机子上运行上面的代码,你可以在次节点机子上看到firefox浏览器被启动,然后打开了www.baidu.com这个网址。
值得注意的是:
相关文章推荐
- Selenium Grid 简易安装--(selenium-server-standalone-*.jar)
- selenium-server-standalone.jar无法启动
- 部署eclipse+junit+selenium未添加selenium-server-standalone-2.46.0.jar抛异常
- mysql简易安装server端+客户端
- Zabbix实战-简易教程(4)--Server端安装
- ubuntu 11.10下简易git server服务器安装架设
- selenium3之selenium-server-standalone-3.8.1.jar启动
- 【问题】selenium-server-standalone和webdriver版本不对应的问题
- 运行selenium-server-standalone.jar时,Firefox无法在***找到该文件
- Selenium Grid 简易安装
- Office Communications Server简易安装配置方法
- centos7服务器无GUI情况下安装使用Xvfb、selenium、chrome和selenium-server
- Mac OS 简易安装redis 标签: redisbrewserverclientMacOS 2016-05-30 23:04 7813人阅读 评论(0) 收藏 举报 分类: Redis 版权声
- ubuntu下python2.7 安装 xlrd、xlwt、pip、 第三方库(library)的简易方法、pip 安装 selenium
- ubuntu下python2.7 安装 xlrd、xlwt、pip、 第三方库(library)的简易方法、pip 安装 selenium
- selenium-server-standalone
- Zabbix监控系列之-Zabbix-Server安装部署
- mysql server的安装和配置
- 规划ISA Server安装
- django 简易博客开发 1 安装、创建、配置、admin使用