`
angelguo
  • 浏览: 118216 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Watir-Webdriver安装与小例子体验

    博客分类:
  • Ruby
阅读更多

一、关于Ruby

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

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

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

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.

 

二、关于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”。它是一种基于网页模式的自动化功能测试工具。

 

三、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

>gem install rdiscount --platform=ruby

 

 

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

 

分享到:
评论

相关推荐

    linux环境下watir-webdriver离线安装包

    3. **下载Watir-Webdriver**: 由于离线安装,你需要先在网上找到Watir-Webdriver的gem文件(.gem),并将其下载到本地。例如,你可以从rubygems.org或镜像站点下载。 4. **安装gem**: 在命令行中,使用`gem install...

    WATIR-WEBDRIVER自动化学习指导

    ### WATIR-WEBDRIVER自动化学习指导 #### 一、简介 WATIR-WEBDRIVER是一款基于Ruby语言的Web自动化测试框架,它能够帮助开发者和测试工程师编写高效的自动化测试脚本。WATIR(Web Application Testing In Ruby)与...

    ruby2.0.0+selenium-webdriver+watir-webdriver+rails离线备份

    ruby2.0.0+selenium-webdriver+watir-webdriver+rails离线备份,设置环境变量后可使用(未测试)

    watir-webdriver谷歌浏览器驱动

    ChromeDriver 是一款以 Google Chrome 为环境测试网站的工具,现已实现对开源的 WebDriver 通路协议的支持,因此可以轻松与现有的 WebDriver 测试工具相整合。不熟悉 WebDriver 的用户可以参考 2009 年的项目发布...

    Watir-Webdriver最新安装文件(全)

    压缩包中包含目前2013/01/19最新的安装文件,有rubyinstaller-1.9.2-p136、DevKit-tdm-32-4.5.1-20101214-1400-sfx、rubygems-1.8.24、watir-4.0.2、watir-webdriver-0.6.2等文件,并附上简略安装说明。

    使用watir-webdriver删除百度空间所有文章的ruby脚本

    使用watir-webdriver删除百度空间所有文章的ruby脚本

    test_logger1.rar_Logger wat_ruby _watir_watir ruby_watir-webdriv

    最后,“watir-webdriver”是Watir的一个分支,它利用Selenium WebDriver接口,直接与浏览器的内核进行通信,增强了对浏览器的控制能力,如处理JavaScript交互、模拟用户行为等。WebDriver是一个跨平台的标准,使得...

    watir-webdriver

    、IEDriverServer.exe rubyinstaller-2.1.5.exe、Ruby语言入门教程v1.0这几个文件,是使用wati-webdriver进行安装部署以及ruby语言学些所需要的必不可少的资料集合,在网上的都是零散的资料,这里能找到全套的。...

    watir安装所需要的gem包

    对于"watir安装所需要的gem包",主要涉及的Gem包有`watir-webdriver`和`selenium-webdriver`。`watir-webdriver`是Watir的一个版本,它使用Selenium WebDriver作为后端,与浏览器进行通信。而`selenium-webdriver`则...

    watir-cn中文补丁包

    watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn...

    页面对象:在watir-webdriver和selenium-webdriver中实现PageObject模式的宝石

    它可以与watir和selenium-webdriver一起使用。 文献资料 项目是学习如何使用页面对象的第一个地方。 可以在上找到该项目的 。 要查看各个发行版之间的更改,请查看 要了解这种宝石的动机,请阅读此 有一本书...

    watir-bonus-1.5.2

    在使用Watir-Bonus前,必须先安装Ruby环境,因为Watir-Bonus是基于Ruby构建的。安装完成后,可以通过Ruby Gem来安装Watir-Bonus库,然后就可以在Ruby脚本中导入并使用它进行Web应用的自动化测试。 总的来说,Watir-...

    win7上搭建cucumber+watir自动化环境

    4. **安装Watir和Watir-webdriver**: Watir-webdriver是Watir的一个分支,专门用于WebDriver接口,支持多种浏览器的自动化测试。安装命令如下: ``` gem install watir-webdriver --no-rdoc --no-ri gem ...

    自动化测试框架

    Ruby与Watir-WebDriver - **Ruby**:一种简洁易读的脚本语言,非常适合用于自动化测试脚本的编写。 - **Watir-WebDriver**:一个用于Web自动化测试的强大库,它允许用户通过编程的方式模拟用户在浏览器中的操作。 ...

    watir-bonus-1.5.1.1230.zip

    4. **doc** - 这个目录可能包含了更广泛的文档,比如用户指南、安装说明、设计理念或其他非API相关的技术文档,帮助用户全面了解和使用Watir-Bonus。 综上所述,这个压缩包是学习和使用Watir测试框架的一个宝贵资源...

    watir-1.5.2.gem

    6. **与其他语言的兼容性**: Watir能与Perl、Python、Shell等其他脚本语言良好集成。 7. **运行时灵活性**: 在测试过程中,用户可以在同一台机器上执行其他任务,而不会影响对象识别。 **Ruby+Watir自动化测试工具...

    cucumber安装

    - 运行命令 `gem install watir-webdriver` 安装 Watir-Webdriver 库。该库用于通过 Webdriver 控制浏览器进行自动化测试。 3. **安装 RSpec**: - 使用命令 `gem install rspec` 安装 RSpec 测试框架。 #### ...

    watir-1.6.5.gem

    开源自动化测试工具组合:Ruby+Watir安装 安装准备: 1. 工具安装包准备: Ruby官方下载地址:http://www.ruby-lang.org/zh_cn/downloads/,稳定版本Ruby 1.8.6 Watir下载地址:...

Global site tag (gtag.js) - Google Analytics