ui_tap
Simulate screen taps on iOS Simulator by specifying coordinates and duration, enabling precise UI testing and interaction control.
Instructions
Tap on the screen in the iOS Simulator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| duration | No | Press duration | |
| udid | No | Udid of target, can also be set with the IDB_UDID env var | |
| x | Yes | The x-coordinate | |
| y | Yes | The x-coordinate |
Implementation Reference
- src/index.ts:288-326 (handler)The handler function that executes the 'idb ui tap' command to tap at specified coordinates on the iOS Simulator screen.async ({ duration, udid, x, y }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "tap", "--udid", actualUdid, ...(duration ? ["--duration", duration] : []), "--json", // When passing user-provided values to a command, it's crucial to use `--` // to separate the command's options from positional arguments. // This prevents the shell from misinterpreting the arguments as options. "--", String(x), String(y) ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Tapped successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error tapping on the screen: ${toError(error).message}` ), }, ], }; } }
- src/index.ts:275-287 (schema)Zod input schema defining parameters: duration (optional), udid (optional), x and y coordinates (required).duration: z .string() .regex(/^\d+(\.\d+)?$/) .optional() .describe("Press duration"), udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), x: z.number().describe("The x-coordinate"), y: z.number().describe("The x-coordinate"), },
- src/index.ts:270-328 (registration)Registration of the 'ui_tap' tool using server.tool(), conditionally filtered by isToolFiltered.if (!isToolFiltered("ui_tap")) { server.tool( "ui_tap", "Tap on the screen in the iOS Simulator", { duration: z .string() .regex(/^\d+(\.\d+)?$/) .optional() .describe("Press duration"), udid: z .string() .regex(UDID_REGEX) .optional() .describe("Udid of target, can also be set with the IDB_UDID env var"), x: z.number().describe("The x-coordinate"), y: z.number().describe("The x-coordinate"), }, async ({ duration, udid, x, y }) => { try { const actualUdid = await getBootedDeviceId(udid); const { stderr } = await idb( "ui", "tap", "--udid", actualUdid, ...(duration ? ["--duration", duration] : []), "--json", // When passing user-provided values to a command, it's crucial to use `--` // to separate the command's options from positional arguments. // This prevents the shell from misinterpreting the arguments as options. "--", String(x), String(y) ); if (stderr) throw new Error(stderr); return { isError: false, content: [{ type: "text", text: "Tapped successfully" }], }; } catch (error) { return { isError: true, content: [ { type: "text", text: errorWithTroubleshooting( `Error tapping on the screen: ${toError(error).message}` ), }, ], }; } } ); }