Class: Maze::Api::Appium::AppManager

Inherits:
Manager
  • Object
show all
Defined in:
lib/maze/api/appium/app_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

#activateObject

Activates the app



12
13
14
15
16
17
18
19
20
21
22
23
24
# 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 => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end

#closeObject

Closes the app (legacy method).



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

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 => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end

#launchObject

Launches the app (legacy method).



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/maze/api/appium/app_manager.rb', line 44

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 => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end

#stateObject

Gets the app state.



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/maze/api/appium/app_manager.rb', line 76

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 => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end

#terminateObject

Terminates the app



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

def terminate
  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 => e
  # Assume the remote appium session has stopped, so crash out of the session
  fail_driver(e.message)
  raise e
end