---
title: "关于watir selenium和webdriver soda cucumber"
author: "夜鸣猪"
date: "2011-11-29T01:34:09Z"
tags: []
categories: ["编程语言"]
slug: "watir-selenium-webdriver-soda-cucumber"
draft: false
lastmod: "2011-11-29T01:34:09Z"
id: 1282183
url: "https://hlee.iteye.com/blog/1282183"
---

watir和selenium在自动化测试web测试领域强硬增长。这一趋势日渐强势，各种搭配和框架丛生。

简单的搜集，我看到了cucumber配合watir的框架，看到例教，和类似的测试集成框架，也看到分布式测试框架


简单使用：

安装

```ruby
gem install watir-webdriver
```


```ruby


require 'watir-webdriver'
b = Watir::Browser.new
b.goto 'bit.ly/watir-webdriver-demo'
b.text_field(:id => 'entry_0').set 'your name'
b.select_list(:id => 'entry_1').select 'Ruby'
b.select_list(:id => 'entry_1').selected? 'Ruby'
b.div(:class => 'ss-form-entry').button.click
b.text.include? 'Thank you'
#webdriver通用watir语法
browser.goto('http://myserver/mypage')
# to enter text into a text field - assuming the field is named 'username'
browser.text_field(:name, 'username').set('Paul')
# if there was a text field that had an id of 'company_ID', you could set it to 'Ruby Co':
browser.text_field(:id ,'company_ID').set('Ruby Co')
# to click a button that has a caption of 'Cancel'
ie.button(:value, 'Cancel').click


```


这一篇，夜猪希望开个头，加强关注这个领域，列一些资源，有机会的话更多学习和接触。
资源一部分：

[书籍watirbook](http://watir.com/book/)

[watir-webdriver不同系统的安装简单应用](https://github.com/zeljkofilipin/watirbook/blob/master/installation/ubuntu.md)

[watir Podcast](http://watirpodcast.com/)

[watir Cheat sheet](http://wiki.openqa.org/display/WTR/Cheat+Sheet)快速差语法用

[watir不错的Tutorial](http://wiki.openqa.org/display/WTR/Tutorial)

soda是用于测试nodejs的selenium client端

[selenium的client](https://github.com/ph7/selenium-client)是之前夜猪自己就一直在用和cucumber配合用的。

在测试的时候，很希望能停下来用firebug测debug一下，就会用到
[capybara-firebug](https://github.com/jfirebaugh/capybara-firebug)


```ruby

# located in features/support/capybara.rb or similar
require 'capybara/firebug'
Selenium::WebDriver::Firefox::Profile.firebug_version = '1.8.3'

profile = Selenium::WebDriver::Firefox::Profile.new
profile.enable_firebug

Capybara::Driver::Selenium.new(app,
   :browser => :remote,
   :url => "http://my.ip.add.ress:4444/wd/hub",
   :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile))

```