mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-06 16:29:37 +08:00
fix: tap_xy, swipe handler
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2505212235
|
v5.0.0-beta-2505212251
|
||||||
|
|||||||
@@ -332,17 +332,11 @@ func (ums *MCPServer4XTDriver) handleTapXY(ctx context.Context, request mcp.Call
|
|||||||
if err := mapToStruct(request.Params.Arguments, &tapReq); err != nil {
|
if err := mapToStruct(request.Params.Arguments, &tapReq); err != nil {
|
||||||
return mcp.NewToolResultError("parse parameters error: " + err.Error()), nil
|
return mcp.NewToolResultError("parse parameters error: " + err.Error()), nil
|
||||||
}
|
}
|
||||||
if tapReq.Duration > 0 {
|
err = driverExt.TapXY(tapReq.X, tapReq.Y,
|
||||||
err := driverExt.Drag(tapReq.X, tapReq.Y, tapReq.X, tapReq.Y,
|
option.WithDuration(tapReq.Duration),
|
||||||
option.WithDuration(tapReq.Duration))
|
option.WithPreMarkOperation(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return mcp.NewToolResultError("Tap failed: " + err.Error()), nil
|
return mcp.NewToolResultError("Tap failed: " + err.Error()), nil
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err := driverExt.TapXY(tapReq.X, tapReq.Y)
|
|
||||||
if err != nil {
|
|
||||||
return mcp.NewToolResultError("Tap failed: " + err.Error()), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return mcp.NewToolResultText(
|
return mcp.NewToolResultText(
|
||||||
fmt.Sprintf("tap (%f,%f) success", tapReq.X, tapReq.Y),
|
fmt.Sprintf("tap (%f,%f) success", tapReq.X, tapReq.Y),
|
||||||
@@ -360,16 +354,22 @@ func (ums *MCPServer4XTDriver) handleSwipe(ctx context.Context, request mcp.Call
|
|||||||
return mcp.NewToolResultError("parse parameters error: " + err.Error()), nil
|
return mcp.NewToolResultError("parse parameters error: " + err.Error()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options := []option.ActionOption{
|
||||||
|
option.WithPreMarkOperation(true),
|
||||||
|
option.WithDuration(swipeReq.Duration),
|
||||||
|
option.WithPressDuration(swipeReq.PressDuration),
|
||||||
|
}
|
||||||
|
|
||||||
// enum direction: up, down, left, right
|
// enum direction: up, down, left, right
|
||||||
switch swipeReq.Direction {
|
switch swipeReq.Direction {
|
||||||
case "up":
|
case "up":
|
||||||
err = driverExt.Swipe(0.5, 0.5, 0.5, 0.1)
|
err = driverExt.Swipe(0.5, 0.5, 0.5, 0.1, options...)
|
||||||
case "down":
|
case "down":
|
||||||
err = driverExt.Swipe(0.5, 0.5, 0.5, 0.9)
|
err = driverExt.Swipe(0.5, 0.5, 0.5, 0.9, options...)
|
||||||
case "left":
|
case "left":
|
||||||
err = driverExt.Swipe(0.5, 0.5, 0.1, 0.5)
|
err = driverExt.Swipe(0.5, 0.5, 0.1, 0.5, options...)
|
||||||
case "right":
|
case "right":
|
||||||
err = driverExt.Swipe(0.5, 0.5, 0.9, 0.5)
|
err = driverExt.Swipe(0.5, 0.5, 0.9, 0.5, options...)
|
||||||
default:
|
default:
|
||||||
return mcp.NewToolResultError(fmt.Sprintf("get unexpected swipe direction: %s", swipeReq.Direction)), nil
|
return mcp.NewToolResultError(fmt.Sprintf("get unexpected swipe direction: %s", swipeReq.Direction)), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ type DragRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SwipeRequest struct {
|
type SwipeRequest struct {
|
||||||
Direction string `json:"direction" binding:"required" desc:"The direction of the swipe. Supported directions: up, down, left, right"`
|
Direction string `json:"direction" binding:"required" desc:"The direction of the swipe. Supported directions: up, down, left, right"`
|
||||||
|
Duration float64 `json:"duration" desc:"Swipe duration in milliseconds (optional)"`
|
||||||
|
PressDuration float64 `json:"press_duration" desc:"Press duration in milliseconds (optional)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppClearRequest struct {
|
type AppClearRequest struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user