diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 6abe9888..10fbe5fc 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v4.3.8.202401201310 \ No newline at end of file +v4.3.8.202404161520 \ No newline at end of file diff --git a/hrp/pkg/uixt/swipe.go b/hrp/pkg/uixt/swipe.go index 4388d9e8..60b84e2d 100644 --- a/hrp/pkg/uixt/swipe.go +++ b/hrp/pkg/uixt/swipe.go @@ -11,10 +11,30 @@ import ( "github.com/httprunner/httprunner/v4/hrp/internal/code" ) +var ( + directionSlice = [][]float64{ + {0.85, 0.83, 0.85, 0.1}, + {0.9, 0.75, 0.9, 0.1}, + {0.6, 0.5, 0.6, 0.1}, + } +) + func assertRelative(p float64) bool { return p >= 0 && p <= 1 } +func (dExt *DriverExt) SwipeUpUtil(count int64, options ...ActionOption) error { + width := dExt.windowSize.Width + height := dExt.windowSize.Height + + fromX := float64(width) * directionSlice[count%3][0] + fromY := float64(height) * directionSlice[count%3][1] + toX := float64(width) * directionSlice[count%3][2] + toY := float64(height) * directionSlice[count%3][3] + + return dExt.Driver.SwipeFloat(fromX, fromY, toX, toY, options...) +} + // SwipeRelative swipe from relative position [fromX, fromY] to relative position [toX, toY] func (dExt *DriverExt) SwipeRelative(fromX, fromY, toX, toY float64, options ...ActionOption) error { width := dExt.windowSize.Width diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 33b89059..5219684a 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -171,14 +171,14 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) { // swipe to next feed video log.Info().Msg("swipe to next feed video") swipeStartTime := time.Now() - if err = dExt.SwipeRelative(0.85, 0.83-(float64(crawler.failedCount)*0.01), 0.85, 0.1, WithOffsetRandomRange(-10, 10)); err != nil { + if err = dExt.SwipeUpUtil(crawler.failedCount, WithOffsetRandomRange(-10, 10)); err != nil { log.Error().Err(err).Msg("feed swipe up failed") return err } swipeFinishTime := time.Now() // get app event trackings - // retry 10 times if get feed failed, abort if fail 10 consecutive times + // retry 3 times if get feed failed, abort if fail 3 consecutive times currentVideo, err := crawler.getCurrentVideo() if err != nil || currentVideo.Type == "" { crawler.failedCount++ @@ -196,19 +196,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) { return err } - if crawler.failedCount > 1 && !isFeed { - // enter live room - entryPoint := PointF{ - X: float64(dExt.windowSize.Width / 2), - Y: float64(dExt.windowSize.Height / 2), - } - - log.Info().Msg("tap screen center to close edge popup") - if err := crawler.driverExt.TapAbsXY(entryPoint.X, entryPoint.Y, - WithOffsetRandomRange(-20, 20)); err != nil { - } - } - // retry continue }