Class: Maze::Api::Appium::AppManager
- Defined in:
- lib/maze/api/appium/app_manager.rb
Overview
Provides operations for working with the app.
Instance Method Summary collapse
-
#activate ⇒ Object
Activates the app.
-
#background(seconds = -1)) ⇒ Object
Instructs Appium to background the app.
-
#close ⇒ Object
Closes the app (legacy method).
-
#launch ⇒ Object
Launches the app (legacy method).
-
#state ⇒ Object
Gets the app state.
-
#terminate(fail_driver = true) ⇒ Object
Terminates the app.
Methods inherited from Manager
#fail_driver, #failed_driver?, #initialize
Constructor Details
This class inherits a constructor from Maze::Api::Appium::Manager
Instance Method Details
#activate ⇒ Object
Activates the app
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/maze/api/appium/app_manager.rb', line 12 def activate if failed_driver? $logger.error 'Cannot activate the app - Appium driver failed.' return false end @driver.activate_app(@driver.app_id) true rescue Selenium::WebDriver::Error::ServerError, Selenium::WebDriver::Error::UnknownError => e $logger.error "Failed to activate app: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#background(seconds = -1)) ⇒ Object
Instructs Appium to background the app
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/maze/api/appium/app_manager.rb', line 49 def background(seconds = -1) if failed_driver? $logger.error 'Cannot background the app - Appium driver failed.' return false end @driver.background_app(seconds) true rescue Selenium::WebDriver::Error::ServerError, Selenium::WebDriver::Error::UnknownError => e $logger.error "Failed to background app: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#close ⇒ Object
Closes the app (legacy method).
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/maze/api/appium/app_manager.rb', line 83 def close if failed_driver? $logger.error 'Cannot close the app - Appium driver failed.' return false end @driver.close_app true rescue Selenium::WebDriver::Error::ServerError, Selenium::WebDriver::Error::UnknownError => e $logger.error "Failed to close app: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#launch ⇒ Object
Launches the app (legacy method).
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/maze/api/appium/app_manager.rb', line 66 def launch if failed_driver? $logger.error 'Cannot launch the app - Appium driver failed.' return false end @driver.launch_app true rescue Selenium::WebDriver::Error::ServerError, Selenium::WebDriver::Error::UnknownError => e $logger.error "Failed to launch app: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#state ⇒ Object
Gets the app state.
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/maze/api/appium/app_manager.rb', line 100 def state if failed_driver? $logger.error('Cannot get the app state - Appium driver failed.') return nil end @driver.app_state(@driver.app_id) rescue Selenium::WebDriver::Error::ServerError, Selenium::WebDriver::Error::UnknownError => e $logger.error "Failed to get app state: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) raise e end |
#terminate(fail_driver = true) ⇒ Object
Terminates the app. If terminate fails then clients may wish to ty the legacy close method, so an option is provided to not fail the Appium driver.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/maze/api/appium/app_manager.rb', line 31 def terminate(fail_driver = true) if failed_driver? $logger.error 'Cannot terminate the app - Appium driver failed.' return false end @driver.terminate_app(@driver.app_id) true rescue Selenium::WebDriver::Error::ServerError, Selenium::WebDriver::Error::UnknownError => e $logger.error "Failed to terminate app: #{e.}" # Assume the remote appium session has stopped, so crash out of the session fail_driver(e.) if fail_driver raise e end |