mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 16:40:50 +08:00
feat: add CheckPopup
This commit is contained in:
+21
-9
@@ -86,7 +86,7 @@ type PopupInfo struct {
|
|||||||
PicURL string `json:"pic_url"`
|
PicURL string `json:"pic_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PopupInfo) getClosePoint() *PointF {
|
func (p *PopupInfo) ClosePoint() *PointF {
|
||||||
closeResult := p.ClosePopupsResult
|
closeResult := p.ClosePopupsResult
|
||||||
if closeResult == nil {
|
if closeResult == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -101,25 +101,37 @@ func (p *PopupInfo) getClosePoint() *PointF {
|
|||||||
return &closePoint
|
return &closePoint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) ClosePopupsHandler() (err error) {
|
func (dExt *DriverExt) CheckPopup() (*PopupInfo, error) {
|
||||||
log.Info().Msg("try to find and close popups")
|
log.Info().Msg("check if popup exist")
|
||||||
|
|
||||||
screenResult, err := dExt.GetScreenResult(
|
screenResult, err := dExt.GetScreenResult(
|
||||||
WithScreenShotUpload(true),
|
WithScreenShotUpload(true),
|
||||||
WithScreenShotClosePopups(true), // get popup area and close area
|
WithScreenShotClosePopups(true), // get popup area and close area
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("get screen result failed for popup handler")
|
return nil, errors.Wrap(err, "get screen result failed for popup handler")
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
popup := screenResult.Popup
|
popup := screenResult.Popup
|
||||||
closePoint := popup.getClosePoint()
|
if popup == nil {
|
||||||
|
return nil, errors.New("popup not found")
|
||||||
|
}
|
||||||
|
closePoint := popup.ClosePoint()
|
||||||
if closePoint == nil {
|
if closePoint == nil {
|
||||||
// close point not found
|
// close point not found
|
||||||
log.Debug().Msg("close point not found")
|
return nil, errors.New("popup close point not found")
|
||||||
|
}
|
||||||
|
log.Info().Interface("popup", popup).Msg("found popup")
|
||||||
|
return popup, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dExt *DriverExt) ClosePopupsHandler() (err error) {
|
||||||
|
log.Info().Msg("try to find and close popups")
|
||||||
|
|
||||||
|
popup, err := dExt.CheckPopup()
|
||||||
|
if err != nil {
|
||||||
|
// no popup found
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
closePoint := popup.ClosePoint()
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Interface("closePoint", closePoint).
|
Interface("closePoint", closePoint).
|
||||||
|
|||||||
Reference in New Issue
Block a user