Giter Site home page Giter Site logo

watir-rspec's Introduction

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 ([email protected]). See LICENSE for details.

watir-rspec's People

Contributors

jarmo avatar p0deje avatar jkotests avatar karlosmid avatar sblond avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.