Class: Henry::Navigator

Inherits:
Object
  • Object
show all
Defined in:
lib/henry/navigator.rb

Overview

Defines a common interface for managing bowsers.

Constant Summary collapse

DRIVERS =
{
  'INTERNET_EXPLORER' => 'ie'
}

Instance Method Summary collapse

Constructor Details

#initialize(driver) ⇒ Navigator

Returns a new instance of Navigator.



10
11
12
13
14
# File 'lib/henry/navigator.rb', line 10

def initialize(driver)
  @driver = DRIVERS[driver] || driver
  
  require @driver.match(/^ie$/i) ? 'watir' : 'watir-webdriver'
end

Instance Method Details

#closeObject

Closes the curretn browser



17
18
19
# File 'lib/henry/navigator.rb', line 17

def close
  browser.close
end

Navigates the given URL

Parameters:

  • ulr (String)

    the target URL.

Returns:



25
26
27
28
29
# File 'lib/henry/navigator.rb', line 25

def navigate(url)
  browser.goto(url)

  return self 
end

#titleString

Returns the curretn browser title.

Returns:

  • (String)

    the browser title.



34
35
36
# File 'lib/henry/navigator.rb', line 34

def title
  browser.title
end