Class: Webdriver::UserAgent::BrowserOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/webdriver-user-agent/browser_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts, user_agent_string) ⇒ BrowserOptions

Returns a new instance of BrowserOptions.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/webdriver-user-agent/browser_options.rb', line 10

def initialize(opts, user_agent_string)
  @options = opts
  options[:browser] ||= :firefox
  options[:agent] ||= :iphone
  options[:orientation] ||= :portrait
  set_preview_option(options[:safari_technology_preview]) if (@options[:browser] == :safari)

  options[:viewport_width], options[:viewport_height] = parse_viewport_sizes(options[:viewport_width], options[:viewport_height])

  initialize_for_browser(user_agent_string)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



22
23
24
25
26
27
# File 'lib/webdriver-user-agent/browser_options.rb', line 22

def method_missing(*args, &block)
  m = args.first
  value = options[m]
  super unless value
  value.downcase
end

Instance Method Details

#browser_optionsObject



29
30
31
# File 'lib/webdriver-user-agent/browser_options.rb', line 29

def browser_options
  options.except(:browser, :agent, :orientation, :user_agent_string, :viewport_width, :viewport_height)
end