Selenium Grid 的机制是启动一个 hub,然后启动多个 Selenium RC 注册到 hub 上,
当测试请求到 hub 时,hub 会将测试分发给 Selenium RC, Selenium RC 会实际的启动一个浏览器完成测试。

grid原理图

安装java jdk 并配置好环境的条件下

1.本机启动hub ( win 7 64bit FF 28.0)

java -jar selenium-server-standalone-2.41.0.jar -role hub -maxSession 40 -port 4444

2.另外一台启动node (win  7 32bit ff 24.5.0),防火墙需要关闭

java -jar selenium-server-standalone-2.41.0.jar -role node \
-hub http://{grid_server}:4444/grid/register -port 5555 \
-firefoxProfileTemplate llinotes.profile -maxSession 20 \
-browser "browserName=firefox,version=28.0,platform=WINDOWS,maxInstances"

在远程机器显示 couldn't register this node,

将node输入命令改成如下:

java -jar selenium-server-standalone-2.41.0.jar -role webdriver \

-hub http://192.168.1.9:4444/grid/register -port 5555 \

-firefoxProfileTemplate llinotes.profile -maxSession 20 \

-browser "browserName=firefox,version=28.0,platform=WINDOWS,maxInstances"

register成功

run hub机器上的脚本

 [Test]
public void Test()
{
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities = DesiredCapabilities.Firefox(); capabilities.SetCapability(CapabilityType.BrowserName, "firefox"); capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); capabilities.SetCapability(CapabilityType.Version, "24.5.0"); driver = new RemoteWebDriver(new Uri("nodeUrl/wd/hub"), capabilities); baseURL = "https://www.google.com/"; verificationErrors = new StringBuilder(); driver.Navigate().GoToUrl(baseURL);
driver.FindElement(By.Id("lst-ib")).SendKeys("selenium");
driver.FindElement(By.Name("btnK")).Click();
}

可以打开Node FF浏览器并进行操作。Done

hub机器显示信息:

node机器显示:

接着又遇到一个问题:如果我要在不同的机器上运行hub上的测试,应该怎么做呢

我试着在另外一台node机器register node(记得关闭防火墙)

在hub机器添加如下代码,将nodeUrl改成其他机器上的ip,运行所有测试,按照测试顺序启动不同机器的浏览器

[Test]
public void Test()
{
DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities = DesiredCapabilities.Firefox(); capabilities.SetCapability(CapabilityType.BrowserName, "firefox"); capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); capabilities.SetCapability(CapabilityType.Version, "28.0"); driver = new RemoteWebDriver(new Uri("nodeUrl2/wd/hub"), capabilities); baseURL = "https://www.google.com/"; verificationErrors = new StringBuilder(); driver.Navigate().GoToUrl(baseURL);
driver.FindElement(By.Id("lst-ib")).SendKeys("selenium");
driver.FindElement(By.Name("btnK")).Click();
}

为了省事,我想把那些命令直接用cmd批处理来执行

新建.txt文件,输入如下内容:
cd selenium-server-standalone-2.41.0.jar路径
java -jar selenium-server-standalone-2.41.0.jar -role hub -maxSession 40 -port 4444

另存为hubstart.bat,双击就能直接运行这个命令启动hub

selenium Grid的更多相关文章

  1. 搭建selenium grid简单配置

    1.使用selenium提供的服务端独立jar包 :服务端.客户端都是运行于java7环境. 2.启动hub: hub配置文件如下: Java -jar selenium-server-standal ...

  2. Robot Framework + Selenium2Library环境下,结合Selenium Grid实施分布式自动化测试

    最近一段时间,公司在推行自动化测试流程,本人有幸参与了自定义通用控件的关键字封装和脚本辅助编写.数据驱动管理.测试用例执行管理等一系列工具软件的研发工作,积累了一些经验,在此与大家做一下分享,也算是做 ...

  3. Selenium Grid 学习笔记

    Selenium Grid 学习笔记http://www.docin.com/p-765680298.html

  4. 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 ...

  5. selenium Grid(一)

    selenium grid Quick Start selenium-grid是用于设计帮助我们进行分布式测试的工具,其整个结构是由一个hub节点和若干个代理节点组成.hub用来管理各个代理节点的注册 ...

  6. selenium grid java 资料

    Grid TestNG: 使用Selenium Grid改进Web应用程序的测试: http://www.ithov.com/server/117464.shtml

  7. Selenium Grid跨浏览器-兼容性测试

    Selenium Grid跨浏览器-兼容性测试 这里有两台机子,打算这样演示: 一台机子启动一个作为主点节的hub 和 一个作为次节点的hub(系统windows 浏览器为ie) ip为:192.16 ...

  8. selenium grid的使用与配置

    一.selenium grid的组成与作用:由一个集线器hub和多个客户机node组成,如果你的程序需要在不用的浏览器,不同的操作系统上测试,而且比较多的case需要多线程远程执行,那么一个比较好的测 ...

  9. 转:Selenium Grid深入学习

    应网友要求写一个用Selenium Grid控制多系统多浏览器并行执行test case的例子. 因为我这里有两台机子,我打算这样演示: 一台机子启动一个作为主点节的hub 和 一个作为次节点的hub ...

随机推荐

  1. IOS调用相机相册

    #import "SendViewController.h"  //只能打开,没有加载图片的代码,老代码,供参考 #import <MobileCoreServices/UT ...

  2. 使用Yeoman搭建 AngularJS 应用 (10) —— 让我们搭建一个网页应用

    原文地址:http://yeoman.io/codelab/write-unit-tests.html 对于不熟悉的Karma的人来说,这是JavaScript测试框架,这个Angular的生成器包含 ...

  3. java程序练习:猜字母

    猜字母程序=数据结构+算法 首先:定义数据结构1.找名词Input:输入变量Output:输出变量隐含:找到隐含的变量,如字符串 其次:定义算法,程序的处理 最后:按照顺序,逐步实现 注意:1.基本数 ...

  4. hadoop Safe mode is ON 的解决办法

    hadoop Safe mode is ON 的解决办法 搭了一个hadoop集群环境,近期总是出现读写文件错误的情况,查看name node的日志显示 (Safe mode is ON) Safe ...

  5. Exploring the 7 Different Types of Data Stories

    Exploring the 7 Different Types of Data Stories What makes a story truly data-driven? For one, the n ...

  6. 团体程序设计天梯赛-练习集L1-011. A-B

    L1-011. A-B 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 本题要求你计算A-B.不过麻烦的是,A和B都是字符串 — ...

  7. "Principles of Reactive Programming" 之<Actors are Distributed> (1)

    week7中的前两节课的标题是”Actors are Distributed",讲了很多Akka Cluster的内容,同时也很难理解. Roland Kuhn并没有讲太多Akka Clus ...

  8. 找出程序cpu使用率高的原因

    确定是CPU过高 使用top观察是否存在CPU使用率过高现象 找出线程 对CPU使用率过高的进程的所有线程进行排序 ps H -e -o pid,tid,pcpu,cmd --sort=pcpu |g ...

  9. VS2005 VS2008 Manifest 配置问题总结

    一.问题 编译某个遗留工程后,运行程序时报错,“由于应用程序的配置不正确,应用程序无法启动.重新安装应用程序可能会解决这个问题.” 查看生成的Manifest文件如下: <?xml versio ...

  10. Linux中的栈:用户态栈/内核栈/中断栈

    http://blog.chinaunix.net/uid-14528823-id-4136760.html Linux中有多种栈,很容易弄晕,简单说明一下: 1.用户态栈:在进程用户态地址空间底部, ...