mobile_long_press_on_screen_at_coordinates
Perform a long press action at specific screen coordinates on mobile devices to trigger context menus, drag-and-drop operations, or element interactions during mobile automation testing.
Instructions
Long press on the screen at given x,y coordinates. If long pressing on an element, use the list_elements_on_screen tool to find the coordinates.
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. | |
| x | Yes | The x coordinate to long press on the screen, in pixels | |
| y | Yes | The y coordinate to long press on the screen, in pixels | |
| duration | No | Duration of the long press in milliseconds. Defaults to 500ms. |
Implementation Reference
- src/server.ts:372-386 (registration)Registers the MCP tool 'mobile_long_press_on_screen_at_coordinates' with Zod input schema (device, x, y) and inline handler that retrieves the Robot for the device and invokes its longPress method.
tool( "mobile_long_press_on_screen_at_coordinates", "Long Press Screen", "Long press on the screen at given x,y coordinates. If long pressing on an element, use the list_elements_on_screen tool to find the coordinates.", { device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."), x: z.number().describe("The x coordinate to long press on the screen, in pixels"), y: z.number().describe("The y coordinate to long press on the screen, in pixels"), }, async ({ device, x, y }) => { const robot = getRobotFromDevice(device); await robot.longPress(x, y); return `Long pressed on screen at coordinates: ${x}, ${y}`; } ); - src/android.ts:441-444 (helper)AndroidRobot implementation of longPress: performs a stationary swipe (ADB input swipe) lasting 500ms at the given coordinates.
public async longPress(x: number, y: number): Promise<void> { // a long press is a swipe with no movement and a long duration this.adb("shell", "input", "swipe", `${x}`, `${y}`, `${x}`, `${y}`, "500"); } - src/ios.ts:199-202 (helper)IosRobot implementation of longPress: delegates to WebDriverAgent (wda) longPress method.
public async longPress(x: number, y: number): Promise<void> { const wda = await this.wda(); await wda.longPress(x, y); } - src/mobile-device.ts:190-192 (helper)MobileDevice (for simulators) implementation of longPress: invokes mobilecli 'io longpress x,y' command.
public async longPress(x: number, y: number): Promise<void> { this.runCommand(["io", "longpress", `${x},${y}`]); } - src/robot.ts:125-125 (helper)Robot interface declaration for the longPress method, implemented by concrete robot classes.
longPress(x: number, y: number): Promise<void>;