Use Watir with RSpec with ease.
Ruby
Latest commit 8f8ce12 Sep 24, 2016 @jarmo jarmo Run specs before releasing.
Permalink
Failed to load latest commit information.
bin
lib/watir Add support for Watir 6.0 and prepare for a new release. Sep 24, 2016
spec Use RSpec 3 syntax in readme/documentation. May 9, 2015
.gitignore Initial commit. Aug 25, 2012
.travis.yml Update Ruby versions in Travis. Sep 24, 2016
.yardopts Add more documentation by using YARD. Jan 3, 2013
CHANGES.md Add support for Watir 6.0 and prepare for a new release. Sep 24, 2016
Gemfile Fix quotes. Sep 21, 2013
LICENSE Remove pointless outdated years from license. Mar 18, 2015
README.md Use RSpec 3 syntax in readme/documentation. May 9, 2015
Rakefile Run specs before releasing. Sep 24, 2016
watir-rspec.gemspec Add support for Watir 6.0 and prepare for a new release. Sep 24, 2016

README.md

Watir::RSpec

Gem Version Build Status Coverage

Use Watir with RSpec with ease.

  • No need to use the @browser or $browser variables when executing browser methods.
  • No need to open the browser in your each test manually.
  • Easily test for asynchronous events by using #within matchers.
  • Easily test that something stays the same within some period by using #during matchers.
  • Get nice html reports with links to html, screenshots and other files generated during test.

Installation

Add these lines to your application's Gemfile:

group :test do
  gem "watir-rspec"
end

Or install it manually as:

gem install watir-rspec

And execute the following command to add watir-rspec configuration into your spec_helper:

watir-rspec install

Usage

Check out the documentation and the straight-forward fully working examples below.

require "spec_helper"

describe "Google" do
  before { goto "http://google.com" }
  
  it "has search box" do
    expect(text_field(name: "q")).to be_present
  end
  
  it "allows to search" do
    text_field(name: "q").set "watir"
    button(id: "gbqfb").click
    results = div(id: "ires")
    expect(results).to be_present.within(2)
    expect(results.lis(class: "g").map(&:text)).to be_any { |text| text =~ /watir/ }
    expect(results).to be_present.during(1)
  end
end

Files created during specs

You can use Watir::RSpec.file_path to have links automatically in the html report to the files created during tests.

uploaded_file_path = Watir::RSpec.file_path("uploaded.txt")
File.open(uploaded_file_path, "w") {|file| file.write "Generated File Input"}
file_field(name: "upload-file").set uploaded_file_path

Rails

You need to use rspec-rails and watir-rails gems together with watir-rspec to achieve maximum satisfaction.

License

Copyright (c) Jarmo Pertman (jarmo.p@gmail.com). See LICENSE for details.