class WatirCrawler::Browser

Public Class Methods

new(timeouts) click to toggle source
# File lib/watir_crawler/browser.rb, line 3
def initialize(timeouts)
  @browser = nil

  @timeouts = {
      :http_client_timeout => 120,
      :implicit_wait => 0,
      :page_load => 100,
      :script_timeout => 10
  }.merge(timeouts)
end

Public Instance Methods

browser() click to toggle source
# File lib/watir_crawler/browser.rb, line 20
def browser
  @browser
end
profile() { |browser_profile| ... } click to toggle source
# File lib/watir_crawler/browser.rb, line 14
def profile
  @browser_profile ||= Selenium::WebDriver::Firefox::Profile.new
  yield @browser_profile if block_given?
  @browser_profile
end
start() click to toggle source
# File lib/watir_crawler/browser.rb, line 24
def start
  return if @browser && @browser.exist?

  # See http://code.google.com/p/selenium/wiki/RubyBindings#Timeouts
  http_client = Selenium::WebDriver::Remote::Http::Default.new
  http_client.timeout = @timeouts[:http_client_timeout]

  @browser = Watir::Browser.new :firefox, :profile => profile, :http_client => http_client
  @browser.driver.manage.timeouts.implicit_wait = @timeouts[:implicit_wait]
  @browser.driver.manage.timeouts.page_load = @timeouts[:page_load]
  @browser.driver.manage.timeouts.script_timeout = @timeouts[:script_timeout]
end
stop() click to toggle source
# File lib/watir_crawler/browser.rb, line 37
def stop
  @browser.close if @browser
end