diff --git a/hrp/pkg/uixt/ocr_vedem.go b/hrp/pkg/uixt/ocr_vedem.go index beb5f0a4..b6b71099 100644 --- a/hrp/pkg/uixt/ocr_vedem.go +++ b/hrp/pkg/uixt/ocr_vedem.go @@ -344,7 +344,7 @@ func (dExt *DriverExt) GetScreenResult() (screenResult *ScreenResult, err error) imageResult, err := dExt.ImageService.GetImage(bufSource) if err != nil { - log.Error().Err(err).Msg("GetScreenResult failed") + log.Error().Err(err).Msg("GetImage from ImageService failed") return } imageResult.imagePath = imagePath diff --git a/hrp/pkg/uixt/swipe.go b/hrp/pkg/uixt/swipe.go index abcdc89b..4419b780 100644 --- a/hrp/pkg/uixt/swipe.go +++ b/hrp/pkg/uixt/swipe.go @@ -135,14 +135,20 @@ func (dExt *DriverExt) swipeToTapTexts(texts []string, options ...ActionOption) var point PointF findTexts := func(d *DriverExt) error { var err error - ocrTexts, err := d.GetScreenTexts() + screenTexts, err := d.GetScreenTexts() if err != nil { return err } - points, err := ocrTexts.FindTexts(texts, dExt.ParseActionOptions(options...)...) + points, err := screenTexts.FindTexts(texts, dExt.ParseActionOptions(options...)...) if err != nil { + // target texts not found, try to auto handle popup + if e := dExt.AutoPopupHandler(screenTexts); e != nil { + log.Error().Err(e).Msg("auto handle popup failed") + } return err } + + // target texts found, pick the first one point = points[0].Center() // FIXME return nil } diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index 7e787775..48672dcc 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -598,13 +598,11 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err } // take screenshot and get screen texts by OCR - screenResult, err2 := uiDriver.GetScreenResult() + screenTexts, err2 := uiDriver.GetScreenTexts() if err2 != nil { log.Error().Err(err2).Str("step", step.Name).Msg("take screenshot failed on step finished") - } - - // automatic handling of pop-up windows on each step finished - if err3 := uiDriver.AutoPopupHandler(screenResult.Texts); err3 != nil { + } else if err3 := uiDriver.AutoPopupHandler(screenTexts); err3 != nil { + // automatic handling of pop-up windows on each step finished log.Error().Err(err3).Msg("auto handle popup failed") }