Class: Maze::Api::Appium::DeviceManager
- Defined in:
- lib/maze/api/appium/device_manager.rb
Overview
Provides operations for working with the app.
Instance Method Summary collapse
-
#back ⇒ Object
Presses the Back button.
-
#get_log(log_type) ⇒ Object
Gets logs from the device.
-
#info ⇒ Object
Gets the device info, in JSON format.
-
#set_rotation(orientation) ⇒ Object
Sets the rotation of the device.
-
#unlock ⇒ Object
Unlocks the device.
Methods inherited from Manager
#fail_driver, #failed_driver?, #initialize
Constructor Details
This class inherits a constructor from Maze::Api::Appium::Manager
Instance Method Details
#back ⇒ Object
Presses the Back button.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/maze/api/appium/device_manager.rb', line 30 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 $logger.error "Failed to press back: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#get_log(log_type) ⇒ Object
Gets logs from the device.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/maze/api/appium/device_manager.rb', line 49 def get_log(log_type) if failed_driver? $logger.error 'Cannot get logs - Appium driver failed.' return nil end @driver.get_log(log_type) rescue Selenium::WebDriver::Error::ServerError => e $logger.error "Failed to get logs: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#info ⇒ Object
Gets the device info, in JSON format
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/maze/api/appium/device_manager.rb', line 83 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 $logger.error "Failed to get the device info: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#set_rotation(orientation) ⇒ Object
Sets the rotation of the device.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/maze/api/appium/device_manager.rb', line 66 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 $logger.error "Failed to set the device rotation: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#unlock ⇒ Object
Unlocks the device.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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 $logger.error "Failed to unlock the device: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |