mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
change: update logs for popup handler
This commit is contained in:
@@ -128,7 +128,7 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
|
||||
}
|
||||
|
||||
popup := screenResult.Popup
|
||||
if popup == nil {
|
||||
if popup == nil || popup.PopupArea.IsEmpty() {
|
||||
log.Debug().Msg("no popup found")
|
||||
break
|
||||
}
|
||||
@@ -145,7 +145,8 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) tapPopupHandler(popup *PopupInfo) error {
|
||||
if popup == nil {
|
||||
if popup == nil || popup.PopupArea.IsEmpty() {
|
||||
log.Debug().Msg("no popup found")
|
||||
return nil
|
||||
}
|
||||
popup.CloseStatus = CloseStatusFound
|
||||
@@ -155,7 +156,8 @@ func (dExt *DriverExt) tapPopupHandler(popup *PopupInfo) error {
|
||||
log.Error().
|
||||
Interface("popup", popup).
|
||||
Msg("popup close area not found")
|
||||
return errors.New("popup close area not found")
|
||||
return errors.Wrap(code.MobileUIPopupError,
|
||||
"popup close area not found")
|
||||
}
|
||||
|
||||
closePoint := popupClose.Center()
|
||||
|
||||
@@ -154,7 +154,7 @@ func (dExt *DriverExt) swipeToTapTexts(texts []string, options ...ActionOption)
|
||||
log.Error().Err(err).Strs("texts", texts).Msg("find texts failed")
|
||||
// target texts not found, try to auto handle popup
|
||||
if e := dExt.tapPopupHandler(screenResult.Popup); e != nil {
|
||||
log.Error().Err(e).Msg("auto handle popup failed")
|
||||
log.Error().Err(e).Msg("tap popup handler failed")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
log.Warn().Msg("get current feed video failed")
|
||||
|
||||
// check and handle popups
|
||||
if err := crawler.driverExt.ClosePopupsHandler(WithMaxRetryTimes(1)); err != nil {
|
||||
if err := crawler.driverExt.ClosePopupsHandler(WithMaxRetryTimes(3)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -234,9 +234,8 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
|
||||
case VideoType_Live:
|
||||
// 直播
|
||||
log.Info().
|
||||
Interface("video", currentVideo).
|
||||
Msg(FOUND_LIVE_SUCCESS)
|
||||
crawler.LiveCount++
|
||||
log.Info().Interface("video", currentVideo).Msg(FOUND_LIVE_SUCCESS)
|
||||
|
||||
// take screenshot and get screen texts by OCR
|
||||
screenResult, err := crawler.driverExt.GetScreenResult(
|
||||
@@ -262,7 +261,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
currentVideo.LiveType = screenResult.imageResult.LiveType
|
||||
}
|
||||
|
||||
crawler.LiveCount++
|
||||
// simulation watch feed video
|
||||
sleepStrict(swipeFinishTime, currentVideo.PlayDuration)
|
||||
|
||||
@@ -295,6 +293,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
default:
|
||||
// 点播 || 图文 || 广告 || etc.
|
||||
crawler.FeedCount++
|
||||
log.Info().Interface("video", currentVideo).Msg(FOUND_FEED_SUCCESS)
|
||||
|
||||
screenResult := &ScreenResult{
|
||||
Resolution: dExt.windowSize,
|
||||
@@ -304,11 +303,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
SwipeStartTime: swipeStartTime.UnixMilli(),
|
||||
SwipeFinishTime: swipeFinishTime.UnixMilli(),
|
||||
}
|
||||
|
||||
dExt.cacheStepData.screenResults[time.Now().String()] = screenResult
|
||||
log.Info().
|
||||
Interface("video", currentVideo).
|
||||
Msg(FOUND_FEED_SUCCESS)
|
||||
|
||||
// simulation watch feed video
|
||||
sleepStrict(swipeFinishTime, currentVideo.PlayDuration)
|
||||
|
||||
@@ -625,7 +625,7 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err
|
||||
|
||||
// automatic handling of pop-up windows on each step finished
|
||||
if err2 := uiDriver.ClosePopups(); err2 != nil {
|
||||
log.Error().Err(err2).Str("step", step.Name).Msg("auto handle popup failed")
|
||||
log.Error().Err(err2).Str("step", step.Name).Msg("handle popup failed on step finished")
|
||||
}
|
||||
|
||||
// save attachments
|
||||
|
||||
Reference in New Issue
Block a user