mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-09 09:27:26 +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
|
popup := screenResult.Popup
|
||||||
if popup == nil {
|
if popup == nil || popup.PopupArea.IsEmpty() {
|
||||||
log.Debug().Msg("no popup found")
|
log.Debug().Msg("no popup found")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,8 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) tapPopupHandler(popup *PopupInfo) 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
|
return nil
|
||||||
}
|
}
|
||||||
popup.CloseStatus = CloseStatusFound
|
popup.CloseStatus = CloseStatusFound
|
||||||
@@ -155,7 +156,8 @@ func (dExt *DriverExt) tapPopupHandler(popup *PopupInfo) error {
|
|||||||
log.Error().
|
log.Error().
|
||||||
Interface("popup", popup).
|
Interface("popup", popup).
|
||||||
Msg("popup close area not found")
|
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()
|
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")
|
log.Error().Err(err).Strs("texts", texts).Msg("find texts failed")
|
||||||
// target texts not found, try to auto handle popup
|
// target texts not found, try to auto handle popup
|
||||||
if e := dExt.tapPopupHandler(screenResult.Popup); e != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
log.Warn().Msg("get current feed video failed")
|
log.Warn().Msg("get current feed video failed")
|
||||||
|
|
||||||
// check and handle popups
|
// check and handle popups
|
||||||
if err := crawler.driverExt.ClosePopupsHandler(WithMaxRetryTimes(1)); err != nil {
|
if err := crawler.driverExt.ClosePopupsHandler(WithMaxRetryTimes(3)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,9 +234,8 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
|
|
||||||
case VideoType_Live:
|
case VideoType_Live:
|
||||||
// 直播
|
// 直播
|
||||||
log.Info().
|
crawler.LiveCount++
|
||||||
Interface("video", currentVideo).
|
log.Info().Interface("video", currentVideo).Msg(FOUND_LIVE_SUCCESS)
|
||||||
Msg(FOUND_LIVE_SUCCESS)
|
|
||||||
|
|
||||||
// take screenshot and get screen texts by OCR
|
// take screenshot and get screen texts by OCR
|
||||||
screenResult, err := crawler.driverExt.GetScreenResult(
|
screenResult, err := crawler.driverExt.GetScreenResult(
|
||||||
@@ -262,7 +261,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
currentVideo.LiveType = screenResult.imageResult.LiveType
|
currentVideo.LiveType = screenResult.imageResult.LiveType
|
||||||
}
|
}
|
||||||
|
|
||||||
crawler.LiveCount++
|
|
||||||
// simulation watch feed video
|
// simulation watch feed video
|
||||||
sleepStrict(swipeFinishTime, currentVideo.PlayDuration)
|
sleepStrict(swipeFinishTime, currentVideo.PlayDuration)
|
||||||
|
|
||||||
@@ -295,6 +293,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
default:
|
default:
|
||||||
// 点播 || 图文 || 广告 || etc.
|
// 点播 || 图文 || 广告 || etc.
|
||||||
crawler.FeedCount++
|
crawler.FeedCount++
|
||||||
|
log.Info().Interface("video", currentVideo).Msg(FOUND_FEED_SUCCESS)
|
||||||
|
|
||||||
screenResult := &ScreenResult{
|
screenResult := &ScreenResult{
|
||||||
Resolution: dExt.windowSize,
|
Resolution: dExt.windowSize,
|
||||||
@@ -304,11 +303,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
SwipeStartTime: swipeStartTime.UnixMilli(),
|
SwipeStartTime: swipeStartTime.UnixMilli(),
|
||||||
SwipeFinishTime: swipeFinishTime.UnixMilli(),
|
SwipeFinishTime: swipeFinishTime.UnixMilli(),
|
||||||
}
|
}
|
||||||
|
|
||||||
dExt.cacheStepData.screenResults[time.Now().String()] = screenResult
|
dExt.cacheStepData.screenResults[time.Now().String()] = screenResult
|
||||||
log.Info().
|
|
||||||
Interface("video", currentVideo).
|
|
||||||
Msg(FOUND_FEED_SUCCESS)
|
|
||||||
|
|
||||||
// simulation watch feed video
|
// simulation watch feed video
|
||||||
sleepStrict(swipeFinishTime, currentVideo.PlayDuration)
|
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
|
// automatic handling of pop-up windows on each step finished
|
||||||
if err2 := uiDriver.ClosePopups(); err2 != nil {
|
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
|
// save attachments
|
||||||
|
|||||||
Reference in New Issue
Block a user