mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
fix: DoubleTapXY
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2502121516
|
v5.0.0+2502121525
|
||||||
|
|||||||
@@ -303,10 +303,14 @@ func (ad *ADBDriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ad *ADBDriver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
func (ad *ADBDriver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
||||||
|
var err error
|
||||||
|
if x, y, err = convertToAbsolutePoint(ad, x, y); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// adb shell input tap x y
|
// adb shell input tap x y
|
||||||
xStr := fmt.Sprintf("%.1f", x)
|
xStr := fmt.Sprintf("%.1f", x)
|
||||||
yStr := fmt.Sprintf("%.1f", y)
|
yStr := fmt.Sprintf("%.1f", y)
|
||||||
_, err := ad.runShellCommand(
|
_, err = ad.runShellCommand(
|
||||||
"input", "tap", xStr, yStr)
|
"input", "tap", xStr, yStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, fmt.Sprintf("tap <%s, %s> failed", xStr, yStr))
|
return errors.Wrap(err, fmt.Sprintf("tap <%s, %s> failed", xStr, yStr))
|
||||||
|
|||||||
@@ -237,10 +237,10 @@ func (ud *UIA2Driver) Orientation() (orientation types.Orientation, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ud *UIA2Driver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
func (ud *UIA2Driver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
||||||
return ud.DoubleFloatTap(x, y)
|
var err error
|
||||||
}
|
if x, y, err = convertToAbsolutePoint(ud, x, y); err != nil {
|
||||||
|
return err
|
||||||
func (ud *UIA2Driver) DoubleFloatTap(x, y float64) error {
|
}
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"actions": []interface{}{
|
"actions": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
@@ -258,7 +258,7 @@ func (ud *UIA2Driver) DoubleFloatTap(x, y float64) error {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := ud.httpPOST(data, "/session", ud.Session.ID, "actions/tap")
|
_, err = ud.httpPOST(data, "/session", ud.Session.ID, "actions/tap")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build localtest
|
||||||
|
|
||||||
package uixt
|
package uixt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ package uixt
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v5/code"
|
|
||||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,22 +36,3 @@ func (dExt *XTDriver) TapByCV(opts ...option.ActionOption) error {
|
|||||||
|
|
||||||
return dExt.TapAbsXY(point.X, point.Y, opts...)
|
return dExt.TapAbsXY(point.X, point.Y, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *XTDriver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
|
||||||
// double tap on coordinate: [x, y] should be relative
|
|
||||||
if x > 1 || y > 1 {
|
|
||||||
return fmt.Errorf("x, y percentage should be < 1, got x=%v, y=%v", x, y)
|
|
||||||
}
|
|
||||||
|
|
||||||
windowSize, err := dExt.WindowSize()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
x = x * float64(windowSize.Width)
|
|
||||||
y = y * float64(windowSize.Height)
|
|
||||||
err = dExt.DoubleTapXY(x, y, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(code.MobileUITapError, err.Error())
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build localtest
|
||||||
|
|
||||||
package uixt
|
package uixt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -545,24 +545,21 @@ func (wd *WDADriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) DoubleTapXY(x, y float64, opts ...option.ActionOption) (err error) {
|
func (wd *WDADriver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
||||||
// [[FBRoute POST:@"/wda/doubleTap"] respondWithTarget:self action:@selector(handleDoubleTapCoordinate:)]
|
// [[FBRoute POST:@"/wda/doubleTap"] respondWithTarget:self action:@selector(handleDoubleTapCoordinate:)]
|
||||||
actionOptions := option.NewActionOptions(opts...)
|
var err error
|
||||||
|
if x, y, err = convertToAbsolutePoint(wd, x, y); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
x = wd.toScale(x)
|
x = wd.toScale(x)
|
||||||
y = wd.toScale(y)
|
y = wd.toScale(y)
|
||||||
if len(actionOptions.Offset) == 2 {
|
|
||||||
x += float64(actionOptions.Offset[0])
|
|
||||||
y += float64(actionOptions.Offset[1])
|
|
||||||
}
|
|
||||||
x += actionOptions.GetRandomOffset()
|
|
||||||
y += actionOptions.GetRandomOffset()
|
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"x": x,
|
"x": x,
|
||||||
"y": y,
|
"y": y,
|
||||||
}
|
}
|
||||||
_, err = wd.httpPOST(data, "/session", wd.Session.ID, "/wda/doubleTap")
|
_, err = wd.httpPOST(data, "/session", wd.Session.ID, "/wda/doubleTap")
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) TouchAndHold(x, y float64, opts ...option.ActionOption) (err error) {
|
func (wd *WDADriver) TouchAndHold(x, y float64, opts ...option.ActionOption) (err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user