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.
-
#execute_script(script) ⇒ Object
Execute script on the device.
-
#get_available_log_types ⇒ Object
Gets available log types on the device.
-
#get_logs(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 |
#execute_script(script) ⇒ Object
Execute script on the device.
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/maze/api/appium/device_manager.rb', line 116 def execute_script(script) if failed_driver? $logger.error 'Cannot execute script on the device - Appium driver failed.' return nil end @driver.execute_script('mobile: shell', command: script) rescue Selenium::WebDriver::Error::ServerError => e $logger.error "Failed execute script on the device: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e) raise e end |
#get_available_log_types ⇒ Object
Gets available log types on the device.
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/maze/api/appium/device_manager.rb', line 48 def get_available_log_types if failed_driver? $logger.error 'Cannot get available log types - Appium driver failed.' return nil end @driver.get_available_log_types rescue Selenium::WebDriver::Error::ServerError => e $logger.error "Failed to get available log types: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e) raise e end |
#get_logs(log_type) ⇒ Object
Gets logs from the device.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/maze/api/appium/device_manager.rb', line 66 def get_logs(log_type) if failed_driver? $logger.error 'Cannot get logs - Appium driver failed.' return nil end @driver.get_logs(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
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/maze/api/appium/device_manager.rb', line 100 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.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/maze/api/appium/device_manager.rb', line 83 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 |