Class: Maze::Api::Appium::DeviceManager

Inherits:
Manager
  • Object
show all
Defined in:
lib/maze/api/appium/device_manager.rb

Overview

Provides operations for working with the app.

Instance Method Summary collapse

Methods inherited from Manager

#fail_driver, #failed_driver?, #initialize

Constructor Details

This class inherits a constructor from Maze::Api::Appium::Manager

Instance Method Details

#backObject

Presses the Back button.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/maze/api/appium/device_manager.rb', line 29

def back
  if failed_driver?
    $logger.error 'Cannot press the Back button - Appium driver failed.'
    return false
  end

  @driver.back
  true
rescue Selenium::WebDriver::Error::ServerError => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end

#infoObject

Gets the device info, in JSON format



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/maze/api/appium/device_manager.rb', line 62

def info
  if failed_driver?
    $logger.error 'Cannot get the device info - Appium driver failed.'
    return nil
  end

  JSON.generate(@driver.device_info)
rescue Selenium::WebDriver::Error::ServerError => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end

#set_rotation(orientation) ⇒ Object

Sets the rotation of the device.

Parameters:

  • orientation (Symbol)

    The orientation to set the device to, :portrait or :landscape



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/maze/api/appium/device_manager.rb', line 46

def set_rotation(orientation)
  if failed_driver?
    $logger.error 'Cannot set the device rotation - Appium driver failed.'
    return false
  end

  @driver.set_rotation(orientation)
  true
rescue Selenium::WebDriver::Error::ServerError => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end

#unlockObject

Unlocks the device.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/maze/api/appium/device_manager.rb', line 13

def unlock
  if failed_driver?
    $logger.error 'Cannot unlock the device - Appium driver failed.'
    return false
  end

  @driver.unlock
  true
rescue Selenium::WebDriver::Error::ServerError => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end