0.03
Low commit activity in last 3 years
No release in over a year
Use Watir with RSpec with ease.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
>= 0

Runtime

~> 3.0
>= 7.2.2
 Project Readme

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.