class Watir::Browser

Reopened Watir::Browser class for working with Rails

Public Class Methods

new(*args) click to toggle source

Will start Rails instance for Watir automatically and then invoke the original Watir::Browser#initialize method.

# File lib/watir/rails/browser.rb, line 9
def initialize(*args)
  Rails.boot
  _original_initialize *args
  add_exception_hook unless Rails.ignore_exceptions?
end
Also aliased as: _original_initialize

Public Instance Methods

_original_goto(url)

@private

Alias for: goto
_original_initialize(*args)

@private

Alias for: new
goto(url) click to toggle source

Opens the url with the browser instance. Will add {Rails.host} and {Rails.port} to the url when path is specified.

@example Go to the regular url:

browser.goto "http://google.com"

@example Go to the controller path:

browser.goto home_path

@param [String] url URL to be navigated to.

# File lib/watir/rails/browser.rb, line 28
def goto(url)
  url = "http://#{Rails.host}:#{Rails.port}#{url}" unless url =~ %r{^(about|data|https?):}i
  _original_goto url
end
Also aliased as: _original_goto

Private Instance Methods

add_exception_hook() click to toggle source
# File lib/watir/rails/browser.rb, line 35
def add_exception_hook
  after_hooks.add do
    if error = Rails.error
      Rails.error = nil
      raise error
    end
  end
end