mobile_swipe_on_screen
Perform screen swipes on mobile devices for automation testing. Swipe in specified directions from defined coordinates to interact with iOS and Android applications.
Instructions
Swipe on the screen
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | Yes | The device identifier to use. Use mobile_list_available_devices to find which devices are available to you. | |
| direction | Yes | The direction to swipe | |
| x | No | The x coordinate to start the swipe from, in pixels. If not provided, uses center of screen | |
| y | No | The y coordinate to start the swipe from, in pixels. If not provided, uses center of screen | |
| distance | No | The distance to swipe in pixels. Defaults to 400 pixels for iOS or 30% of screen dimension for Android |
Implementation Reference
- src/server.ts:456-481 (registration)Registration of the 'mobile_swipe_on_screen' tool, including input schema definition and handler function that delegates to the appropriate Robot instance's swipe or swipeFromCoordinate method based on provided coordinates.tool( "mobile_swipe_on_screen", "Swipe Screen", "Swipe on the screen", { device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), direction: z.enum(["up", "down", "left", "right"]).describe("The direction to swipe"), x: z.number().optional().describe("The x coordinate to start the swipe from, in pixels. If not provided, uses center of screen"), y: z.number().optional().describe("The y coordinate to start the swipe from, in pixels. If not provided, uses center of screen"), distance: z.number().optional().describe("The distance to swipe in pixels. Defaults to 400 pixels for iOS or 30% of screen dimension for Android"), }, async ({ device, direction, x, y, distance }) => { const robot = getRobotFromDevice(device); if (x !== undefined && y !== undefined) { // Use coordinate-based swipe await robot.swipeFromCoordinate(x, y, direction, distance); const distanceText = distance ? ` ${distance} pixels` : ""; return `Swiped ${direction}${distanceText} from coordinates: ${x}, ${y}`; } else { // Use center-based swipe await robot.swipe(direction); return `Swiped ${direction} on screen`; } } );