watir webdriver 安装

注释:如下内容转自:http://www.cnblogs.com/huberypang/archive/2012/05/29/2522857.html 谢谢Hubery Pangphp

Watir-Webdriver安装与小例子体验html

转载请注明出处:http://www.cnblogs.com/huberypang/archive/2012/05/29/2522857.htmlgit

1、关于Rubygithub

Ruby is a cross-platform interpreted language which has many features in common with other 'scripting' language such as Perl and Python.web

 It has an 'English language' style syntax which looks somewhat Pascal-like at first sight. windows

It is thoroughly object oriented, and has a good deal in common with the great-granddaddy of 'pure' OO languages, Smalltalk. ruby

It has been said that the languages which most influenced the development of Ruby were:Perl, Smalltalk,Eiffel,Ada and Lisp. 服务器

The Ruby language was created by Matz and it was first released in 1995.app

 

2、关于Watir工具

 Watir  =  Web Application Testing in Ruby

 

Watir project is a collection of open source tools that drive browsers and help you automate boring and repetitive parts of functional testing of web applications, so you have more time to test with your brain.

 Watir, pronounced "water", is an acronym standing for "Web Application Testing in Ruby". Watir is a toolkit used to automate browser-based tests during web application development.

 

Watir全称是“Web Application Testing in Ruby”,发音相似“water”。它是一种基于网页模式的自动化功能测试工具。

 

3、Ruby + Watir 安装方法

 

1、安装Ruby

 <Ruby下载地址>

http://rubyforge.org/frs/?group_id=167&release_id=44412

 软件被墙了,能够在这下载:http://ishare.iask.sina.com.cn/f/24668376.html

 

Ruby安装方法直接next就能够了。可是有一个注意点,以下面英文内容所说。

You can leave all settings at default values, expect at the Installation Destination and Optional Tasks screen check both 'Add Ruby executables to your Path' and 'Associate .rb and .rbw files with this Ruby installation checkboxes.

 

安装好以后,check下是否Ruby安装成功了。

cmd窗口键入【Ruby -v】命令,能正常显示所安装的Ruby版本,就说明安装成功了。

 

2、安装DevKit

 <DevKit下载地址>

https://github.com/oneclick/rubyinstaller/wiki/development-kit

 软件被墙了,能够在这下载:http://ishare.iask.sina.com.cn/f/24668446.html

 

在下面的第三步中将要升级RubyGems,而要能正常升级RubyGems,系统就必要要安装好DevKit

 

另,windows下安装或升级时gem常常会碰到

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
这是由于没有安装DevKit的缘故,也是由于被墙了,因此得下载离线安装包安装

 

安装命令以下:

> cd <DEVKIT_INSTALL_DIR>

> ruby dk.rb init

> ruby dk.rb review

> ruby dk.rb install

 

 

3、升级RubyGems

Software written in Ruby is usually distributed as RubyGems, Ruby package manager. Sometimes Ruby installations do not have the latest versions of RubyGems, so we will first update it. RubyGems is also a gem, and we get it's version with gem -v.

 

首先,cmd窗口键入下面命令确认当前的RubyGems版本。

>gem -v

 

其次,cmd窗口键入下面命令进行RubyGems的升级。

>gem update --system

 

最后,再次在cmd窗口键入下面命令确认当前的RubyGems版本,应该就能更新到最新版本了。

>gem -v

 

RubyGems是一个方便而强大的Ruby程序包管理器( package manager),相似RedHatRPM.它将一个Ruby应用程序打包到一个gem里,做为一个安装单元。无需安装,最新的Ruby版本已经包含RubyGems了。

特色:

能远程安装包

包之间依赖关系的管理

简单可靠的卸载(uninstallation

查询机制,能查询本地和远程服务器的包信息

能保持一个包的不一样版本

基于Web的查看接口,能查看你安装的gem的信息。

  

使用:

1. gem query --remote        # shortcut: gem q -R

#列出全部包

2. gem query --remote --name-matches doom   # shortcut: gem q -R -n doom

#列出全部名字匹配的包

3. gem install --remote progressbar  # shortcut: gem i -r progressbar

#安装指定名字的包。

gem ins -r progressbar --version '> 0.0.1' #这里能够匹配版本

4. gem specification  progressbar  # shortcut: gem spec progressbar

#查看安装过的指定包详细信息

5.gem uninstall progressbar

#卸载包

6. gem query --local # shortcut: 'gem q -L'

#列出全部本地安装过的包

7. gem ins rake

#在本地安装,若是没有远程安装

8. gem list -b ^C

#列出全部以C开头的包

9. gem_server

开启rdoc服务。能够查看安装包的rdoc

 

 

4、安装watir

cmd窗口键入下面命令进行watir安装 

>gem install watir

或者

>gem install watir --no-ri --no-rdoc

区别在于后面一个命令没有安装Ruby的一些说明文档,因此速度较快。

 

 

5、最后安装watir-webdriver

 在cmd窗口键入下面命令进行watir-webdriver安装

 >gem install watir-webdriver

 

Ruby+Watir-Webdriver最终安装完毕。

 

6.实践watir-Webdriver小实例

cmd窗口键入下面命令irb,irb是Ruby的解释器,能够逐行解释ruby语句。在irb逐行输入以下代码,用watir-webdriver实现打开网站并关闭,体现效果

require 'watir-webdriver'

a=Watir::Browser.new           ----Watir与Browser必须大写

a.goto 'http://bbs.naxsu.com/forum.php'

a.close

 

相关文章
相关标签/搜索