Selenium Grid 安装
来源:互联网 发布:windows损坏文件修复 编辑:程序博客网 时间:2024/06/05 03:58
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这个网址。
值得注意的是:
WebDriver dr =
new
RemoteWebDriver(
new
URL(
"http://192.168.4.137:5555/wd/hub"
),test);
这一句中的192.168.4.137为次节点的ip地址。
0 0
- Selenium Grid 安装
- Selenium Grid简介与安装
- selenium grid
- Selenium Grid
- Selenium Grid.
- Selenium Grid
- Selenium 第一炮--Selenium Grid
- Selenium Grid 简易安装--(selenium-server-standalone-*.jar)
- Selenium Grid 简易安装--(selenium-server-standalone-*.jar)
- 如何使用Selenium-Grid
- Selenium-Grid工作方式
- Selenium Grid 学习笔记
- selenium grid简单使用说明
- Webdriver - Selenium Grid Configuration
- 如何使用Selenium-Grid
- Selenium-Grid 参数说明
- Selenium Grid Parallel
- Selenium Grid 分享
- [C#] Byte[]、Image、Bitmap 之间的相互转换
- php--get_defined_constants()
- Win32 api编程模板和 加速键编程例子
- IOS Number 处理(int-->NSNumber,NSNumber-->nsinteger,string -->double,CGFloat --> dobule)
- Dumpbin命令使用详解
- Selenium Grid 安装
- 设计模式-策略模式
- 2014-03-13周四:Setlocale函数设置当前程序使用的本地化信息
- java内存溢出调试工具
- oracle 存储过程经典实例
- C++常用函数备忘
- Win7 & VS2013 编译 WebKit 总结
- NSScanner类的基本用法
- 自考之—我看《操作系统概论》