mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
feat: add auto popups handler in swipe find
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user