From a72690baad2bf026cc4e90e356274a409b87f0cf Mon Sep 17 00:00:00 2001 From: "xucong.053" Date: Fri, 14 Oct 2022 13:15:14 +0800 Subject: [PATCH 1/2] fix: failed to load customDirection from ui automation json script --- hrp/pkg/uixt/swipe.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hrp/pkg/uixt/swipe.go b/hrp/pkg/uixt/swipe.go index 5cb8bffa..8f2ba9f9 100644 --- a/hrp/pkg/uixt/swipe.go +++ b/hrp/pkg/uixt/swipe.go @@ -3,6 +3,7 @@ package uixt import ( "fmt" + "github.com/httprunner/httprunner/v4/hrp/internal/builtin" "github.com/rs/zerolog/log" ) @@ -86,6 +87,14 @@ func (dExt *DriverExt) SwipeUntil(direction interface{}, condition FindCondition if err := dExt.SwipeRelative(d[0], d[1], d[2], d[3]); err != nil { log.Error().Err(err).Msgf("swipe %s failed", d) } + } else if d, ok := direction.([]interface{}); ok { + sx, _ := builtin.Interface2Float64(d[0]) + sy, _ := builtin.Interface2Float64(d[1]) + ex, _ := builtin.Interface2Float64(d[2]) + ey, _ := builtin.Interface2Float64(d[3]) + if err := dExt.SwipeRelative(sx, sy, ex, ey); err != nil { + log.Error().Err(err).Msgf("swipe (%v, %v) to (%v, %v) failed", sx, sy, ex, ey) + } } } return fmt.Errorf("swipe %s %d times, match condition failed", direction, maxTimes) From e936d8afb2835c075d512869280d476f5281988c Mon Sep 17 00:00:00 2001 From: "xucong.053" Date: Fri, 14 Oct 2022 15:28:24 +0800 Subject: [PATCH 2/2] fix: failed to filter out point(0,0) --- hrp/pkg/uixt/ext.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index e38ffc56..564bad59 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -444,7 +444,7 @@ func (dExt *DriverExt) DoAction(action MobileAction) error { return err } for _, point = range points { - if point != (PointF{}) { + if point != (PointF{X: 0, Y: 0}) { return nil } }