0.0
No commit activity in last 3 years
No release in over 3 years
This gem leverages the Watir test library to allow for easy access to configurarion and session data so they do not need to be passed around as parameters throughout your tests.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0

Runtime

~> 6.0
 Project Readme

WatirSession

This gem leverages the Watir test library to allow for easy access to configurarion and session data so they do not need to be passed around as parameters throughout your tests. The intention is to provide a solution that is easy to use and maintain, while still providing power and flexibility.

Installation

Add this line to your application's Gemfile:

gem 'watir_session'

And then execute:

$ bundle

Or install it yourself as:

$ gem install watir_session

Usage

The default WatirConfig class uses the recommended settings without needing 
 any modifications. 
The hooks into the WatirSession class are designed to work with your 
test harness (RSpec, Cucumber, etc) for maximum flexibility. 
At a minimum, you'll need to call:

WatirSession.start

WatirSession.before_each


WatirSession.after_each



Example

Here's an example for how you can add a session for Saucelabs

class SauceSession
  def initialize
    @sauce_config = SuaceConfig.new
  end
  def create_browser)
    @browser = Watir::Browser.new(:remote, url: @sauce_config.endpoint)
  end
end
require 'watir_model'

class SauceConfig < WatirModel
  key(:sauce_username) { ENV['SAUCE_USERNAME'] }
  key(:sauce_access_key) { ENV['SAUCE_ACCESS_KEY'] }
  key(:endpoint) {"http://#{sauce_username}:#{sauce_access_key}@ondemand.saucelabs.com:80/wd/hub"}
end
RSpec.configure do |config|
  WatirSession.start
  WatirSession.register_session(SauceSession.new)

  config.before(:each) do
    @browser = WatirSession.before_each
  end
  config.after(:each) do
    WatirSession.after_each
  end
end

Development

Run rake spec to run the tests To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/titusfortner/watir_session.

License

The gem is available as open source under the terms of the MIT License.