mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
fix: raise error if close area not found to popup
This commit is contained in:
+14
-21
@@ -62,31 +62,18 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
|
|||||||
log.Error().Err(err).Msg("get screen result failed for popup handler")
|
log.Error().Err(err).Msg("get screen result failed for popup handler")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
screenResult.Popup.RetryCount = retryCount
|
|
||||||
|
|
||||||
// 1. there are no popups here (fast return normally)
|
popup := screenResult.Popup
|
||||||
// 2. failed to close popup (maybe tap error, return error)
|
if popup == nil {
|
||||||
// 3. successful to close popup (sleep and wait for next retry if existed)
|
|
||||||
if screenResult.Popup == nil {
|
|
||||||
log.Debug().Msg("no popup found")
|
log.Debug().Msg("no popup found")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
popup.RetryCount = retryCount
|
||||||
|
|
||||||
// popup found
|
if err = dExt.tapPopupHandler(popup); err != nil {
|
||||||
if !screenResult.Popup.PopupArea.IsEmpty() {
|
|
||||||
screenResult.Popup.CloseStatus = CloseStatusFound
|
|
||||||
}
|
|
||||||
if screenResult.Popup.CloseArea.IsEmpty() {
|
|
||||||
log.Warn().Msg("popup close area not found")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
screenResult.Popup.CloseStatus = CloseStatusFound
|
|
||||||
|
|
||||||
if err = dExt.tapPopupHandler(screenResult.Popup); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().Interface("popup", screenResult.Popup).Msg("close popup success")
|
|
||||||
// sleep for another popup (if existed) to pop
|
// sleep for another popup (if existed) to pop
|
||||||
time.Sleep(time.Duration(1000*interval) * time.Millisecond)
|
time.Sleep(time.Duration(1000*interval) * time.Millisecond)
|
||||||
}
|
}
|
||||||
@@ -97,12 +84,17 @@ func (dExt *DriverExt) tapPopupHandler(popup *PopupInfo) error {
|
|||||||
if popup == nil {
|
if popup == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if popup.CloseArea.IsEmpty() {
|
popup.CloseStatus = CloseStatusFound
|
||||||
log.Warn().Msg("popup close area not found")
|
|
||||||
return nil
|
popupClose := popup.CloseArea
|
||||||
|
if popupClose.IsEmpty() {
|
||||||
|
log.Error().
|
||||||
|
Interface("popup", popup).
|
||||||
|
Msg("popup close area not found")
|
||||||
|
return errors.New("popup close area not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
closePoint := popup.CloseArea.Center()
|
closePoint := popupClose.Center()
|
||||||
log.Info().
|
log.Info().
|
||||||
Interface("popup", popup).
|
Interface("popup", popup).
|
||||||
Interface("closePoint", closePoint).
|
Interface("closePoint", closePoint).
|
||||||
@@ -111,6 +103,7 @@ func (dExt *DriverExt) tapPopupHandler(popup *PopupInfo) error {
|
|||||||
log.Error().Err(err).Msg("tap popup failed")
|
log.Error().Err(err).Msg("tap popup failed")
|
||||||
return errors.Wrap(code.MobileUIPopupError, err.Error())
|
return errors.Wrap(code.MobileUIPopupError, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// tap popup success
|
// tap popup success
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ func (dExt *DriverExt) swipeToTapTexts(texts []string, options ...ActionOption)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
points, err := screenResult.Texts.FindTexts(texts, dExt.ParseActionOptions(optionsWithoutIdentifier...)...)
|
points, err := screenResult.Texts.FindTexts(texts,
|
||||||
|
dExt.ParseActionOptions(optionsWithoutIdentifier...)...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user