class Actir::Webdriver::BrowserOptions
Public Class Methods
new(opts, user_agent_string)
click to toggle source
# File lib/actir/webdriver/browser_options.rb, line 7 def initialize(opts, user_agent_string) @options = opts options[:browser] ||= :chrome options[:agent] ||= :iphone #options[:orientation] ||= :portrait initialize_for_browser(user_agent_string) end
Public Instance Methods
browser_options()
click to toggle source
# File lib/actir/webdriver/browser_options.rb, line 22 def browser_options #options.except(:browser, :agent, :orientation) options.except(:browser, :agent) end
method_missing(*args, &block)
click to toggle source
Calls superclass method
# File lib/actir/webdriver/browser_options.rb, line 15 def method_missing(*args, &block) m = args.first value = options[m] super unless value value.downcase end
Private Instance Methods
initialize_for_browser(user_agent_string)
click to toggle source
# File lib/actir/webdriver/browser_options.rb, line 33 def initialize_for_browser(user_agent_string) case options[:browser] when :firefox options[:profile] ||= Selenium::WebDriver::Firefox::Profile.new options[:profile]['general.useragent.override'] = user_agent_string when :chrome options[:switches] ||= [] options[:switches] << "--user-agent=#{user_agent_string}" # add bu Hub # support phantomjs when :phantomjs options[:desired_capabilities] ||= Selenium::WebDriver::Remote::Capabilities.phantomjs( "phantomjs.page.settings.userAgent" => user_agent_string ) else raise "WebDriver currently only supports :chrome, :firefox and :phantomjs" end end
options()
click to toggle source
# File lib/actir/webdriver/browser_options.rb, line 29 def options @options ||= {} end