Class: Maze::Hooks::AppiumHooks
- Inherits:
-
InternalHooks
- Object
- InternalHooks
- Maze::Hooks::AppiumHooks
- Defined in:
- lib/maze/hooks/appium_hooks.rb
Overview
Hooks for Appium mode use
Instance Method Summary collapse
Methods inherited from InternalHooks
Instance Method Details
#after(scenario) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/maze/hooks/appium_hooks.rb', line 25 def after(scenario) $logger.debug "Appium after hook" manager = Maze::Api::Appium::AppManager.new if Maze.config.os == 'macos' # Close the app - without the sleep launching the app for the next scenario intermittently fails system("killall -KILL #{Maze.config.app} && sleep 1") elsif [:bb, :bs, :local].include?(Maze.config.farm) && Maze.config.browser.nil? close_fallback = Maze.config.appium_version && Maze.config.appium_version.to_f < 2.0 begin manager.terminate(!close_fallback) rescue Selenium::WebDriver::Error::UnknownError, Selenium::WebDriver::Error::InvalidSessionIdError => e if close_fallback $logger.warn 'terminate_app failed, using the slower but more forceful close_app instead' manager.close else $logger.warn 'terminate_app failed, future errors may occur if the application did not close properly' end end # Reset the server before relaunching the app to ensure that test fixtures cannot fetch # commands from the previous scenario (in idempotent mode). Maze::Server.reset! manager.activate if Maze.config.browser.nil? end rescue => error # Notify and re-raise for Cucumber to handle Bugsnag.notify error raise end |
#after_all ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/maze/hooks/appium_hooks.rb', line 56 def after_all if @client @client.log_run_outro $logger.info 'Stopping the Appium session' @client.stop_session end rescue => error # Notify and re-raise for Cucumber to handle Bugsnag.notify error raise end |
#before(scenario) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/maze/hooks/appium_hooks.rb', line 17 def before(scenario) @client.start_scenario rescue => error # Notify and re-raise for Cucumber to handle Bugsnag.notify error raise end |