fix: failed to swipe up

This commit is contained in:
徐聪
2024-06-04 22:03:48 +08:00
parent 46ea78eaf3
commit 4599c47bcb
3 changed files with 23 additions and 16 deletions
+20
View File
@@ -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