Class: Watir::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/watir/rails/browser.rb

Overview

Reopened Watir::Browser class for working with Rails

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Browser

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



9
10
11
12
13
# File 'lib/watir/rails/browser.rb', line 9

def initialize(*args)
  Rails.boot
  _original_initialize *args
  add_exception_hook unless Rails.ignore_exceptions?
end

Instance Method Details

#goto(url)

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

Examples:

Go to the regular url:

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

Go to the controller path:

browser.goto home_path

Parameters:

  • url (String)

    URL to be navigated to.



28
29
30
31
# 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