module Thoran::Selenium::WebDriver::Setup

Public Instance Methods

setup(path_or_browser) click to toggle source
# File lib/Thoran/Selenium/WebDriver/Setup/setup.rb, line 27
def setup(path_or_browser)
  if File.exist?(File.expand_path(path_or_browser.to_s))
    path = path_or_browser
    at(path)
    ::Selenium::WebDriver.for(selenium_browser(path))
  else
    browser = path_or_browser.to_sym.downcase
    ::Selenium::WebDriver.for(browser)
  end
end

Private Instance Methods

at(path) click to toggle source
# File lib/Thoran/Selenium/WebDriver/Setup/setup.rb, line 40
def at(path)
  selenium_binary_constant(path).path = File.expand_path(path)
end
selenium_binary_constant(path) click to toggle source

This method seem to be necessary only to Firefox, since there are no equivalent constants for Safari or Chrome.

# File lib/Thoran/Selenium/WebDriver/Setup/setup.rb, line 53
def selenium_binary_constant(path)
  "Selenium::WebDriver::#{selenium_browser(path).to_s.capitalize}::Binary".to_const
end
selenium_browser(path) click to toggle source
# File lib/Thoran/Selenium/WebDriver/Setup/setup.rb, line 44
def selenium_browser(path)
  case path
  when /chrome/i; :chrome
  when /firefox/i; :firefox
  when /safari/i; :safari
  end
end