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. selenium + python网页自动化测试环境搭建

    1.python的安装 ,这个不解释,exe文件运行安装即可,既然你选择python,相信你是熟悉python的,我安装目录C:\Python27 2.setuptools 的安装也非常简单,同样是e ...

  2. 应该如何入门deep learning呢?从UFLDL开始!

    抱歉,大家,这里不是要分享如何学习deep learning,而是想要记录自己学习deep learning的小历程,算是给自己的一点小动力吧,希望各位业内前辈能够多多指教! 看到有网友提到,Andr ...

  3. Recommender Systems 基于知识的推荐

    前两章的协同过滤和就内容的推荐都建立在“大量数据”的基础上,运用概率方法来进行计算和预测.不过,在现实生活中,有些物品,如:汽车.房屋.计算机,用户不会频繁的消费.如何在这种情况下对用户进行推荐? 这 ...

  4. AndroidManifest.xml文件综合详解(转)

    一,重要性AndroidManifest.xml是Android应用程序中最重要的文件之一.它是Android程序的全局配置文件,是每个 android程序中必须的文件.它位于我们开发的应用程序的根目 ...

  5. uva 10810

    刘汝佳书上 143  归并排序求逆序数对 #include <cstdio> #include <cstring> #include <cstdlib> #incl ...

  6. JSP中脚本、声明和表达式的本质区别

     JSP脚本元素 使用JSP脚本元素可以将Java代码嵌入到JSP页面里,这些Java代码将出现在由当前JSP页面生成的Servlet中,使JSP将静态内容与动态内容分离出来.脚本元素包含:  1. ...

  7. Eclipse 调整代码颜色的地方

    Editors - Text Editors General-Apperance-Colors and Fonts 各工作区里面的Editor和Syntax Coloring

  8. Tiny6410 交叉编译helloworld程序

    在工作目录下建立helloworld.c文件 #include <stdio.h> main() { printf("helloworld!\n"); } 保存关闭后. ...

  9. MetadataType的使用

    MetadataType的使用,MVC的Model层数据验证指定要与数据模型类关联的元数据类 using System.ComponentModel.DataAnnotations; //指定要与数据 ...

  10. 用java运行Hadoop程序报错:org.apache.hadoop.fs.LocalFileSystem cannot be cast to org.apache.

    用java运行Hadoop例程报错:org.apache.hadoop.fs.LocalFileSystem cannot be cast to org.apache.所写代码如下: package ...