Class: Webdriver::UserAgent::Driver

Inherits:
Object
  • Object
show all
Includes:
Singleton, Devices
Defined in:
lib/webdriver-user-agent/driver.rb

Instance Method Summary collapse

Methods included from Devices

#agent_string_for, #devices, #resolution_for

Instance Method Details

#for(opts) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/webdriver-user-agent/driver.rb', line 13

def for(opts)
  user_agent_string   = opts[:user_agent_string]
  user_agent_string ||= agent_string_for opts[:agent]
  options = BrowserOptions.new(opts, user_agent_string)
  build_driver_using options
ensure
  if safari?(opts)
    case
    when opts[:safari_technology_preview].is_a?(TrueClass)
      `defaults delete com.apple.SafariTechnologyPreview CustomUserAgent`
      `defaults delete com.apple.SafariTechnologyPreview AppleLanguages`
    else
      `defaults delete com.apple.Safari CustomUserAgent`
      `defaults delete com.apple.Safari AppleLanguages`
    end
  end
end