mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
fix: failed to swipe up
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v4.3.8.202401201310
|
v4.3.8.202404161520
|
||||||
@@ -11,10 +11,30 @@ import (
|
|||||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
"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 {
|
func assertRelative(p float64) bool {
|
||||||
return p >= 0 && p <= 1
|
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]
|
// SwipeRelative swipe from relative position [fromX, fromY] to relative position [toX, toY]
|
||||||
func (dExt *DriverExt) SwipeRelative(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
func (dExt *DriverExt) SwipeRelative(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
||||||
width := dExt.windowSize.Width
|
width := dExt.windowSize.Width
|
||||||
|
|||||||
@@ -171,14 +171,14 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
// swipe to next feed video
|
// swipe to next feed video
|
||||||
log.Info().Msg("swipe to next feed video")
|
log.Info().Msg("swipe to next feed video")
|
||||||
swipeStartTime := time.Now()
|
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")
|
log.Error().Err(err).Msg("feed swipe up failed")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
swipeFinishTime := time.Now()
|
swipeFinishTime := time.Now()
|
||||||
|
|
||||||
// get app event trackings
|
// 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()
|
currentVideo, err := crawler.getCurrentVideo()
|
||||||
if err != nil || currentVideo.Type == "" {
|
if err != nil || currentVideo.Type == "" {
|
||||||
crawler.failedCount++
|
crawler.failedCount++
|
||||||
@@ -196,19 +196,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
return err
|
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
|
// retry
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user