From 780fe2b0020e35acc2e1ff6e63c5e41b08b3d018 Mon Sep 17 00:00:00 2001 From: buyuxiang <347586493@qq.com> Date: Mon, 28 Aug 2023 19:05:54 +0800 Subject: [PATCH] replace AutoPopupHandler with ClosePopupsHandler --- hrp/pkg/uixt/swipe.go | 10 +++++++--- hrp/pkg/uixt/video_crawler.go | 2 +- hrp/step_mobile_ui.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hrp/pkg/uixt/swipe.go b/hrp/pkg/uixt/swipe.go index 6b4a72ce..e3cf7f01 100644 --- a/hrp/pkg/uixt/swipe.go +++ b/hrp/pkg/uixt/swipe.go @@ -137,15 +137,19 @@ func (dExt *DriverExt) swipeToTapTexts(texts []string, options ...ActionOption) var point PointF findTexts := func(d *DriverExt) error { var err error - screenTexts, err := d.GetScreenTexts() + screenResult, err := d.GetScreenResult( + WithScreenShotOCR(true), + WithScreenShotUpload(true), + WithScreenShotClosePopups(true), + ) if err != nil { return err } - points, err := screenTexts.FindTexts(texts, dExt.ParseActionOptions(options...)...) + points, err := screenResult.Texts.FindTexts(texts, dExt.ParseActionOptions(options...)...) if err != nil { log.Error().Err(err).Msg("swipeToTapTexts failed") // target texts not found, try to auto handle popup - if e := dExt.handleTextPopup(screenTexts); e != nil { + if e := dExt.tapPopupHandler(screenResult.Popup); e != nil { log.Error().Err(e).Msg("auto handle popup failed") } return err diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 26d57f4e..0f8a1f75 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -317,7 +317,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) { if feedVideo.VideoID == crawler.lastFeed.VideoID { // app event tracking not changed // check and handle popups - if err = crawler.driverExt.AutoPopupHandler(); err != nil { + if err = crawler.driverExt.ClosePopupsHandler(WithMaxRetryTimes(1)); err != nil { return err } } diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index 50e22cbb..09a3f194 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -624,7 +624,7 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err } // automatic handling of pop-up windows on each step finished - if err2 := uiDriver.AutoPopupHandler(); err2 != nil { + if err2 := uiDriver.ClosePopups(); err2 != nil { log.Error().Err(err2).Str("step", step.Name).Msg("auto handle popup failed") }