Sha256: 54045929bc6fc0f5a0dfaae61a481fcf1f101f8647a0f75ca7cc044038f08234
Contents?: true
Size: 1.44 KB
Versions: 31
Compression:
Stored size: 1.44 KB
Contents
require 'facets/hash/except' module Actir module Webdriver class BrowserOptions def initialize(opts, user_agent_string) @options = opts options[:browser] ||= :chrome options[:agent] ||= :iphone #options[:orientation] ||= :portrait initialize_for_browser(user_agent_string) end def method_missing(*args, &block) m = args.first value = options[m] super unless value value.downcase end def browser_options #options.except(:browser, :agent, :orientation) options.except(:browser, :agent) end private def options @options ||= {} end 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 end end end
Version data entries
31 entries across 31 versions & 1 rubygems