replace AutoPopupHandler with ClosePopupsHandler

This commit is contained in:
buyuxiang
2023-08-28 19:05:54 +08:00
parent b0ccd504de
commit 780fe2b002
3 changed files with 9 additions and 5 deletions

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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")
}