Module: Applitools::Appium::Utils

Extended by:
Utils
Includes:
Utils::EyesSeleniumUtils
Included in:
Utils
Defined in:
lib/applitools/appium/utils.rb

Instance Method Summary collapse

Instance Method Details

#android?(driver) ⇒ Boolean

true if test is running on Android device

Returns:

  • (Boolean)


16
17
18
# File 'lib/applitools/appium/utils.rb', line 16

def android?(driver)
  driver.respond_to?(:device_is_android?) && driver.device_is_android?
end

#current_scroll_position(driver) ⇒ Object



58
59
60
61
62
# File 'lib/applitools/appium/utils.rb', line 58

def current_scroll_position(driver)
  super
rescue
  Applitools::Location::TOP_LEFT
end

#device_pixel_ratio(executor) ⇒ Object

Parameters:

  • executor (Applitools::Selenium::Driver)


31
32
33
34
35
# File 'lib/applitools/appium/utils.rb', line 31

def device_pixel_ratio(executor)
  session_info = session_capabilities(executor)
  return session_info['pixelRatio'].to_f if session_info['pixelRatio']
  1
end

#ios?(driver) ⇒ Boolean

true if test is running on iOS device

Returns:

  • (Boolean)


21
22
23
# File 'lib/applitools/appium/utils.rb', line 21

def ios?(driver)
  driver.respond_to?(:device_is_ios?) && driver.device_is_ios?
end

#mobile_device?(driver) ⇒ Boolean

true if test is running on mobile device

Returns:

  • (Boolean)


9
10
11
12
13
# File 'lib/applitools/appium/utils.rb', line 9

def mobile_device?(driver)
  defined?(Appium::Driver) &&
      defined?(Applitools::Appium::Driver::AppiumLib) &&
      Applitools::Appium::Driver::AppiumLib
end

#platform_version(driver) ⇒ Object

Parameters:

  • driver (Applitools::Selenium::Driver)


26
27
28
# File 'lib/applitools/appium/utils.rb', line 26

def platform_version(driver)
  driver.respond_to?(:platform_version) && driver.platform_version
end

#session_capabilities(executor) ⇒ Object



54
55
56
# File 'lib/applitools/appium/utils.rb', line 54

def session_capabilities(executor)
   executor.session_capabilities if executor.respond_to? :session_capabilities
end

#status_bar_height(executor) ⇒ Object



37
38
39
40
41
# File 'lib/applitools/appium/utils.rb', line 37

def status_bar_height(executor)
  session_info = session_capabilities(executor)
  return session_info['statBarHeight'].to_i if session_info['statBarHeight']
  0
end

#viewport_rect(executor) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/applitools/appium/utils.rb', line 43

def viewport_rect(executor)
  session_info = session_capabilities(executor)
  return session_info['viewportRect'] if session_info['viewportRect']
  {
    'left' => 0,
    'top' => 0,
    'width' => 0,
    'height' => 0
  }
end