Grid的安装与使用一

  • 简介

  Selenium Grid是一种自动化的测试辅助工具,Grid通过利用现有的计算机基础设施,能加快Web-app的功能测试。利用Grid,可以很方便地同时在多台机器上和异构环境中并行运行多个测试事例。  Selenium Grid基于Web-app测试工具Selenium,它可以让您同时并行运行多个Selenium Remote Control。比较好的一点事,它使所有这些Selenium Remote Control显示为一个,这样您在测试中就可以不必操作具体的计算机。  Selenium Grid因为是基于Selenium RC的,所以它同时支持RC的其它所有语言,如:Ruby, Java, Python, C#, PHP, …  还有最后一点,Selenium Grid简单易用。

  • 原理图

  • 使用

  下面,我们就介绍下如何使用Selenium Grid。

  •  准备:
  1. 下载安装ant

  http://apache.mirrormax.net/ant/binaries/apache-ant-1.7.0-bin.zip  解压包到你选择的任意目录,然后将 你的解压路径/apache-ant-1.7.0/bin 添加的Path变量中。  最后验证安装:  java -version  java version “1.6.0”  Java(TM) SE Runtime Environment (build 1.6.0-b105)  Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)

  1. 下载Selenium Grid

  http://selenium-grid.seleniumhq.org/download.html  其中,zip是Windows平台的,tar.bz2用于其他平台。下载后解压缩,然后验证:  ant sanity-check

  • 运行:

 在Selenium2.0之前,Selenium Grid是独立提供服务的。自2.0之后,Selenium Grid被集成到了Selenium Server中了(包含在selenium-server-standalone-.jar中)。Starting a Hub

To start a hub with default parameters, run the following command from a command-line shell. This will work on all the supported platforms, Windows Linux, or MacOs.

java -jar selenium-server-standalone-2.21.0.jar -role hub

This starts a hub using default parameter values. We’ll explain these parameters in folowing subsections. Note that you will likely have to change the version number in the jar filename depending on which version of the selenium-server you’re using.Starting a Node

To start a node using default parameters, run the following command from a command-line.

java -jar selenium-server-standalone-2.21.0.jar -role node -hub http://localhost:4444/grid/register

This assumes the hub has been started above using default parameters. The default port the hub uses to listen for new requests is port 4444. This is why port 4444 was used in theURL for locating the hub. Also the use of ‘localhost’ assumes your node is running on the same machine as your hub. For getting started this is probably easiest. If running the hub and node on separate machines, simply replace ‘localhost’ with the hostname of the remote machine running the hub.

WARNING: Be sure to turn off the firewalls on the machine running your hub and nodes. Otherwise you may get connection errors.

  • 使用Selenium Grid与普通的Selenium Server的区别在于是否带上了-role参数。

# 启动Selenium Serverjava –jar selenium-server-standalone-2.22.0.jar -port 4444 # 启动Selenium Grid的Hubjava –jar selenium-server-standalone-2.22.0.jar -port 4000 -role hub

# 启动Selenium Grid的Node,其中的-hub参数,是Selenium Grid的Hub的URLjava -jar selenium-server-standalone-2.22.0.jar -port 4001 -role node -hubhttp://127.0.0.1:4000/grid/register

#显然,可以启动多个Node:java -jar selenium-server-standalone-2.22.0.jar -port 4002 -role node -hubhttp://127.0.0.1:4000/grid/register

java -jar selenium-server-standalone-2.22.0.jar -port 4003 -role node -hub http://127.0.0.1:4000/grid/register

……例如,

  1. hub:
  2. node:

  通过浏览器访问Selenium Grid控制台验证Selenium Grid启动成功:  http://localhost:4444/console

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值