mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 08:27:35 +08:00
DoubleTap支持绝对坐标
This commit is contained in:
@@ -312,12 +312,15 @@ func (ad *ADBDriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *ADBDriver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
func (ad *ADBDriver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
|
||||||
var err error
|
var err error
|
||||||
if x, y, err = convertToAbsolutePoint(ad, x, y); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
actionOptions := option.NewActionOptions(opts...)
|
actionOptions := option.NewActionOptions(opts...)
|
||||||
|
if !actionOptions.AbsCoordinate {
|
||||||
|
x, y, err = convertToAbsolutePoint(ad, x, y)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
x, y = actionOptions.ApplyOffset(x, y)
|
x, y = actionOptions.ApplyOffset(x, y)
|
||||||
|
|
||||||
// adb shell input tap x y
|
// adb shell input tap x y
|
||||||
@@ -542,12 +545,12 @@ func (ad *ADBDriver) SetRotation(rotation types.Rotation) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ad *ADBDriver) ScreenShot(opts ...option.ActionOption) (raw *bytes.Buffer, err error) {
|
func (ad *ADBDriver) ScreenShot(opts ...option.ActionOption) (raw *bytes.Buffer, err error) {
|
||||||
resp, err := ad.runShellCommand("screencap", "-p")
|
resp, err := ad.Device.ScreenCap()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(code.DeviceScreenShotError,
|
return nil, errors.Wrapf(code.DeviceScreenShotError,
|
||||||
"adb screencap failed %v", err)
|
"adb screencap failed %v", err)
|
||||||
}
|
}
|
||||||
raw = bytes.NewBuffer([]byte(resp))
|
raw = bytes.NewBuffer(resp)
|
||||||
|
|
||||||
actionOptions := option.NewActionOptions(opts...)
|
actionOptions := option.NewActionOptions(opts...)
|
||||||
if actionOptions.ScreenShotFileName != "" {
|
if actionOptions.ScreenShotFileName != "" {
|
||||||
|
|||||||
@@ -252,12 +252,15 @@ func (ud *UIA2Driver) Orientation() (orientation types.Orientation, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ud *UIA2Driver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
func (ud *UIA2Driver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
|
||||||
var err error
|
var err error
|
||||||
if x, y, err = convertToAbsolutePoint(ud, x, y); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
actionOptions := option.NewActionOptions(opts...)
|
actionOptions := option.NewActionOptions(opts...)
|
||||||
|
if !actionOptions.AbsCoordinate {
|
||||||
|
x, y, err = convertToAbsolutePoint(ud, x, y)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
x, y = actionOptions.ApplyOffset(x, y)
|
x, y = actionOptions.ApplyOffset(x, y)
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
|
|||||||
@@ -290,15 +290,6 @@ func (wd *BrowserWebDriver) Hover(x, y float64) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *BrowserWebDriver) DoubleTapXY(x, y float64, option ...option.ActionOption) (err error) {
|
|
||||||
data := map[string]interface{}{
|
|
||||||
"x": x,
|
|
||||||
"y": y,
|
|
||||||
}
|
|
||||||
_, err = wd.HttpPOST(data, wd.sessionId, "ui/double_tap")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wd *BrowserWebDriver) Input(text string, option ...option.ActionOption) (err error) {
|
func (wd *BrowserWebDriver) Input(text string, option ...option.ActionOption) (err error) {
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"text": text,
|
"text": text,
|
||||||
|
|||||||
+3
-3
@@ -50,9 +50,9 @@ type IDriver interface {
|
|||||||
Unlock() error
|
Unlock() error
|
||||||
Back() error
|
Back() error
|
||||||
// tap
|
// tap
|
||||||
TapXY(x, y float64, opts ...option.ActionOption) error // by percentage
|
TapXY(x, y float64, opts ...option.ActionOption) error // by percentage
|
||||||
TapAbsXY(x, y float64, opts ...option.ActionOption) error // by absolute coordinate
|
TapAbsXY(x, y float64, opts ...option.ActionOption) error // by absolute coordinate
|
||||||
DoubleTapXY(x, y float64, opts ...option.ActionOption) error // by percentage
|
DoubleTap(x, y float64, opts ...option.ActionOption) error // by percentage
|
||||||
TouchAndHold(x, y float64, opts ...option.ActionOption) error
|
TouchAndHold(x, y float64, opts ...option.ActionOption) error
|
||||||
// swipe
|
// swipe
|
||||||
Drag(fromX, fromY, toX, toY float64, opts ...option.ActionOption) error
|
Drag(fromX, fromY, toX, toY float64, opts ...option.ActionOption) error
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ func (dExt *XTDriver) DoAction(action MobileAction) (err error) {
|
|||||||
return fmt.Errorf("invalid tap location params: %v", params)
|
return fmt.Errorf("invalid tap location params: %v", params)
|
||||||
}
|
}
|
||||||
x, y := params[0], params[1]
|
x, y := params[0], params[1]
|
||||||
return dExt.DoubleTapXY(x, y)
|
return dExt.DoubleTap(x, y)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("invalid %s params: %v", ACTION_DoubleTapXY, action.Params)
|
return fmt.Errorf("invalid %s params: %v", ACTION_DoubleTapXY, action.Params)
|
||||||
case ACTION_Swipe:
|
case ACTION_Swipe:
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func NewStubAndroidDriver(dev *uixt.AndroidDevice) (*StubAndroidDriver, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setup driver
|
// setup driver
|
||||||
if err := driver.Setup(); err != nil {
|
if err = driver.Setup(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ func (hd *HDCDriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
|
|||||||
ghdc.NewGesture().Start(ghdc.Point{X: int(x), Y: int(y)}).Pause(100))
|
ghdc.NewGesture().Start(ghdc.Point{X: int(x), Y: int(y)}).Pause(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hd *HDCDriver) DoubleTapXY(x, y float64, opts ...option.ActionOption) error {
|
func (hd *HDCDriver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
|
||||||
return types.ErrDriverNotImplemented
|
return types.ErrDriverNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -105,9 +105,9 @@ func (r *Router) doubleTapHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tapReq.X < 1 && tapReq.Y < 1 {
|
if tapReq.X < 1 && tapReq.Y < 1 {
|
||||||
err = driver.DoubleTapXY(tapReq.X, tapReq.Y)
|
err = driver.DoubleTap(tapReq.X, tapReq.Y)
|
||||||
} else {
|
} else {
|
||||||
err = driver.DoubleTapXY(tapReq.X, tapReq.Y,
|
err = driver.DoubleTap(tapReq.X, tapReq.Y,
|
||||||
option.WithAbsoluteCoordinate(true))
|
option.WithAbsoluteCoordinate(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user