Class: Applitools::Selenium::RenderBrowserInfo

Inherits:
IRenderBrowserInfo show all
Defined in:
lib/applitools/selenium/visual_grid/render_browser_info.rb

Constant Summary collapse

DEFAULT_CONFIG =
proc do
  {
      platform: 'linux',
      browser_type: BrowserTypes::CHROME,
      # size_mode: 'full-page',
      viewport_size: Applitools::RectangleSize.from_any_argument(width: 0, height: 0)
  }
end

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RenderBrowserInfo

Returns a new instance of RenderBrowserInfo.



25
26
27
28
29
30
31
# File 'lib/applitools/selenium/visual_grid/render_browser_info.rb', line 25

def initialize(options = {})
  super
  if options[:width] && options[:height]
    self.viewport_size = Applitools::RectangleSize.from_any_argument(width: options[:width], height: options[:height])
  end
  self.browser_type = options[:browser_type] if options[:browser_type]
end

Class Method Details

.default_configObject



20
21
22
# File 'lib/applitools/selenium/visual_grid/render_browser_info.rb', line 20

def default_config
  DEFAULT_CONFIG.call
end

Instance Method Details

#device_nameObject



52
53
54
55
56
57
58
59
# File 'lib/applitools/selenium/visual_grid/render_browser_info.rb', line 52

def device_name
  if ios_device_info
    return ios_device_info.device_name
  elsif emulation_info
    return emulation_info.device_name + ' (chrome emulation)'
  end
  'desktop'
end

#platformObject



33
34
35
36
37
38
39
40
41
# File 'lib/applitools/selenium/visual_grid/render_browser_info.rb', line 33

def platform
  return 'ios' if ios_device_info
  case browser_type
  when BrowserType::EDGE_LEGACY, BrowserType::EDGE_CHROMIUM, BrowserType::EDGE_CHROMIUM_ONE_VERSION_BACK
    'windows'
  else
    'linux'
  end
end

#to_sObject



43
44
45
46
47
48
49
50
# File 'lib/applitools/selenium/visual_grid/render_browser_info.rb', line 43

def to_s
  if emulation_info
    "#{emulation_info.device_name} - #{emulation_info.screen_orientation}"
  elsif ios_device_info
    "#{ios_device_info.device_name} - #{ios_device_info.screen_orientation}"
  end
  "#{viewport_size} (#{browser_type})"
end