Class: Watir::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/watir/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
# File 'lib/watir/browser.rb', line 9

def initialize(*args)
  Rails.boot
  original_initialize *args
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:

Open the regular url:

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

Open the controller path:

browser.goto home_path

Parameters:

  • url (String)

    URL to be navigated to.



27
28
29
30
# File 'lib/watir/browser.rb', line 27

def goto(url)
  url = "http://#{Rails.host}:#{Rails.port}#{url}" unless url =~ %r{^https?://}i || url == "about:blank"
  original_goto url
end