SwiftMonkey icon indicating copy to clipboard operation
SwiftMonkey copied to clipboard

Find a quick way to see if the monkey manages to leave the application

Open DagAgren opened this issue 9 years ago • 5 comments

Try to find out if there is a way to detect from test code if the application has been exited so the test can stop.

DagAgren avatar Nov 22 '16 10:11 DagAgren

To detect if app is currently running or not:

let isRunning = XCUIApplication().running
print("Application is currently running: \(isRunning)")

To detect if app is currently active or not:

if ((FBApplication.fb_active()?.label)! == "YoursAppName") {
   // still in app
} else {
   // not in app anymore
}

it checks if current active application on screen has proper label - but it requires WebDriverAgentLib to be included in project. It also properly detects stuff like: notification bar overlay on app, control center, etc.

I'm not sure if checking for active app is possible with current XCTest API.

@DagAgren what would you like to achieve in this issue? if application gets crashed/is not running anymore - just finish the tests? as a fail?

drptbl avatar Dec 02 '16 10:12 drptbl

Added functionality to return to the app if Monkey exited it accidentally

DmitryBespalov avatar Nov 01 '17 19:11 DmitryBespalov

Thank you!

drptbl avatar Nov 01 '17 20:11 drptbl

This solution kind of solved the problem but this solution will start the test even after the test fails.

singh88 avatar Nov 07 '17 21:11 singh88

@singh88 even if continueAfterFailure = true for a test was set?

DmitryBespalov avatar Dec 15 '17 10:12 DmitryBespalov