Selenium WebDriver + Grid2 + RSpec之旅(二)

----Grid2的配置

为什么要使用Selenium-Grid

  • 分布式运行大规模的TestCase
  • 能够通过一个中央节点,很容易的运行不同OS上的不同Browser
  • 最小化对Grid的维护时间,充分利用虚拟设备
  • 减少测试人员的工作量,提高测试效率

Selenium-Grid的部署与启动

Hub:总控节点,连接调用Node,负责分配用例到对应的Node节点所在的执行器上Node

Node:负责执行TestCase,启动浏览器

由于作者苦逼屌丝一枚,资源有限,就以一台机器为例,版本对应selenium-server-standalone-2.37.0.jar:

启动Hub:

通过windows的DOS窗口进入selenium-server-standalone-2.37.0.jar所在目录

执行命令java -jar selenium-server-standalone-2.37.0.jar -role hub 启动hub,运行界面如下:

在浏览器中访问:http://localhost:4444/grid/console可以查看Hub状态。

Hub默认启动端口为4444,如果要修改端口的话,就在命令后面加参数 -port 。如要修改端口为9999,执行命令为:

java -jar selenium-server-standalone-2.37.0.jar -role hub -port 9999

启动Node:

Node可以不和Hub部署在不同的机器上,在这里我们是部署在同一台机器上,方法和启动Hub类似,只是命令不同

java -jar selenium-server-standalone-2.37.0.jar  -role node -hub http://localhost:4444/grid/register -browser browserName="internet explorer",version=10,platform=WINDOWS

Node默认启动端口是5555,如果要换端口的话,方法和Hub一样后面加-port参数,这里http://localhost:4444/grid/register指的是Hub的地址,如果Hub的IP为192.168.1.100端口为5678的话,应该为http://192.168.1.100:5678/grid/register

如果要启动Firefox和chrome的话 同样也可以添加Node,添加的时候要注意防止端口冲突

java -jar selenium-server-standalone-2.37.0.jar -Dwebdriver.firefox.bin="C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -role  webdriver -hub http://localhost:4444/grid/register -browser browserName=firefox -port 6666

java -jar selenium-server-standalone-2.37.0.jar -Dwebdriver.chrome.driver="D:\BrowserDriver\chromedriver.exe" -role webdriver -hub http://localhost:4444/grid/register -port 7777 -browser browserName=chrome

然后,在浏览器中访问:http://localhost:4444/grid/console可以查看Hub状态

至此,Selenium Grid2已经配置成功了。

Node配置

在浏览器中访问:http://localhost:4444/grid/console,把鼠标放到各个浏览器图标上,就可以看到Node的配置信息

内容类似:

{       "platform": "VISTA",

"seleniumProtocol": "WebDriver",

"browserName": "firefox"     }

其中,seleniumProtocol就是定义的协议了。

如何修改Driver配置呢?可以从启动参数里操作。

browser browserName="internet explorer",version=10,platform=WINDOWS

那Node默认启动的配置是什么呢?
由于如果从启动参数里,配置这个多东西,很难写的。因此,官方很人性化的提供了JSON文件来配置。也就是说默认启动的配置如下: http://code.google.com/p/selenium/source/browse/trunk/java/server/src/org/openqa/grid/common/defaults/DefaultNode.json

http://code.google.com/p/selenium/source/browse/trunk/java/server/src/org/openqa/grid/common/defaults/DefaultHub.json

如果想自定义配置,直接对json文件修改,启动时,指定配置文件就可以了。

java -jar selenium-server-standalone-2.37.0.jar -role hub -hubConfig hubconfig.json 仅仅就这样就行了?从博文http://www.shenyanchao.cn/blog/2012/10/12/selenium-multiple-browser-support/知道,浏览器的启动是要制定一些driver位置的,否则Node不知道怎么启动浏览器实例。因此需要进行指定:

java -jar selenium-server-standalone-2.37.0.jar -port 7777 -role node -hub http://10.81.14.180:8888/grid/register  -nodeConfig nodeconfig.json -Dwebdriver.chrome.driver="D:\BrowserDriver\chromedriver.exe"

参考文档: http://code.google.com/p/selenium/wiki/Grid2

Selenium WebDriver + Grid2 + RSpec之旅(二)----Grid2的配置的更多相关文章

  1. Selenium WebDriver + Grid2 + RSpec之旅(四) ----通过RSpec编写测试用例

    Selenium WebDriver + Grid2 + RSpec之旅(四) ----通过RSpec编写测试用例 自动化测试和手工测试一样,是要有测试用例,有检查点和测试结果的,接下来我们通过RSp ...

  2. Selenium WebDriver + Grid2 + RSpec之旅(六) ----多浏览器的并行执行

    Selenium WebDriver + Grid2 + RSpec之旅(六) ----多浏览器的并行执行 由于浏览器的发展,浏览器种类繁多.为了保证系统能在各种浏览器上叱咤风云,减少测试人员的测试工 ...

  3. Selenium WebDriver + Grid2 + RSpec之旅(五)---面向对象设计用例

    Selenium WebDriver + Grid2 + RSpec之旅(五) ----面向对象设计用例 前几节讲了怎么一步一步的从零开始到编写出一个简单的测试用例,这一节将要讲一下怎么让测试用例变得 ...

  4. Selenium WebDriver + Grid2 + RSpec之旅(三) ----入门小例子

    Selenium WebDriver + Grid2 + RSpec之旅(三) ----入门小例子 第一个例子都是比较简单的博客园登录界面,就像学习编程语言时候都是从Hello,World!开始. 1 ...

  5. Selenium WebDriver + Grid2 + RSpec之旅(一)----准备篇

    Selenium WebDriver + Grid2 + RSpec之旅(一)             ----准备篇 前言 在Web 2.0 应用中,在浏览器种类盛行的时代,我们在测试过程中不仅要模 ...

  6. selenium webdriver API详解(二)

    本系列主要讲解webdriver常用的API使用方法(注意:使用前请确认环境是否安装成功,浏览器驱动是否与谷歌浏览器版本对应) 一:获取当前页面的title(一般获取title用于断言) from s ...

  7. Selenium (2) —— Selenium WebDriver + Grid2(101 Tutorial)

    Selenium (2) -- Selenium WebDriver + Grid2(101 Tutorial) jvm版本: 1.8.0_65 selenium版本: v2.48.0 (Standa ...

  8. selenium webdriver 学习笔记(二)

    selenium webdriver 一.定位一组元素: webdriver可以很方便的使用findElement 方法来定位某个物定的对象.不过有时候我们却要定位一组对象,这时候就需要使用findE ...

  9. Python3 Selenium自动化web测试 ==> 第十一节 WebDriver高级应用 -- 显示等待 + 二次封装

    学习目的: 掌握显示等待 掌握二次封装 正式步骤: step1:显示等待的代码示例 # -*- coding:utf-8 -*- from selenium import webdriver from ...

随机推荐

  1. Eclipse使用Maven创建Web项目

    一.Maven插件下载.jdk下载 1.maven下载地址: http://maven.apache.org/download.cgi 2.jdk下载地址: http://www.oracle.com ...

  2. Java 的自动装箱拆箱

    Java 是面向对象的语言,其基本数据类型也就有了相对应的类,称为包装类.以下是基本数据类型对应的包装类: 基本数据类型 包装类 byte(1字节) Byte short(2字节) Short int ...

  3. 九度OJ 1468 Sharing -- 哈希

    题目地址:http://ac.jobdu.com/problem.php?pid=1468 题目描述: To store English words, one method is to use lin ...

  4. 理解Http协议(一)

    本文对Http协议进行了简要的描述,说明了其用途的广泛性:通过代码对Http连接和Http请求消息的发送进行实现,希望能将这些抽象的过程直观的显示出来:最后对HttpURL和Http协议中“资源”这些 ...

  5. centos 安装php-fpm , nginx二级域名配置 ,但为什么必须要 域名提供商 哪里解析新的二级域名一下 才能用呢?

    yum -y install php-fpm php-mysql(当然还有其它扩展) /etc/init.d/php-fpm restart (重启php-fpm) /etc/php.ini (php ...

  6. $.ajax参数备注-转转转

    jquery中的ajax方法参数总是记不住,这里记录一下.  $,ajax()方法参数详解 1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为St ...

  7. skip index scan

    官网对skip index scan的解释: Index skip scans improve index scans by nonprefix columns since it is often f ...

  8. Using .NET 4's Lazy<T> 实现单实例

    Using .NET 4's Lazy<T> type Explanation of the following code: If you're using .NET 4 (or high ...

  9. POJ 2252 Dungeon Master 三维水bfs

    题目: http://poj.org/problem?id=2251 #include <stdio.h> #include <string.h> #include <q ...

  10. App 性能分析

    关键因素: ---- Instrument 性能分析神器 1. 启动时间 应用启动时间长短对用户第一次体验至关重要,同时系统对应用的启动.恢复等状态的运行时间也有严格的要求,在应用超时的情况下系统会直 ...