mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-25 01:59:52 +08:00
feat: check if app is in foreground when step failed
This commit is contained in:
@@ -561,6 +561,14 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err
|
||||
attachments := make(map[string]interface{})
|
||||
if err != nil {
|
||||
attachments["error"] = err.Error()
|
||||
|
||||
// check if app is in foreground
|
||||
packageName := uiDriver.Driver.GetLastLaunchedApp()
|
||||
yes, err2 := uiDriver.Driver.IsAppInForeground(packageName)
|
||||
if packageName != "" && (!yes || err2 != nil) {
|
||||
log.Error().Err(err2).Str("packageName", packageName).Msg("app is not in foreground")
|
||||
err = errors.Wrap(code.MobileUIAppNotInForegroundError, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// take screenshot after each step
|
||||
|
||||
Reference in New Issue
Block a user