Skip to main content
Glama
andreahaku
by andreahaku

ui.swipe

Simulate swipe gestures on iOS app elements for UI testing and automation. Specify direction, speed, and distance to interact with React Native/Expo interfaces in the simulator.

Instructions

Swipe on an element in a direction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesElement selector to swipe on.
directionYesSwipe direction.
speedNoSwipe speed.fast
percentageNoSwipe distance as percentage of element.

Implementation Reference

  • Registration of the 'ui.swipe' MCP tool, including inline handler that generates a Detox swipe snippet and executes it via runDetoxAction
    server.tool( "ui.swipe", "Swipe on an element in a direction", UiSwipeInputSchema.shape, async (args) => { try { const snippet = generateSwipeSnippet({ selector: args.selector, direction: args.direction, speed: args.speed, percentage: args.percentage, }); const result = await runDetoxAction({ actionName: `swipe:${args.direction}:${describeSelector(args.selector)}`, actionSnippet: snippet, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; } catch (error) { return handleToolError(error); } } );
  • Zod schema for ui.swipe tool input validation, including selector, direction, speed, and percentage parameters
    export const UiSwipeInputSchema = z.object({ selector: SelectorSchema.describe("Element selector to swipe on."), direction: DirectionSchema.describe("Swipe direction."), speed: z.enum(["fast", "slow"]).optional().default("fast").describe("Swipe speed."), percentage: z.number().min(0).max(1).optional().default(0.75).describe("Swipe distance as percentage of element."), });
  • Helper function generateSwipeSnippet that creates the Detox JavaScript code snippet for performing a swipe action on an element
    export interface SwipeOptions { selector: Selector; direction: Direction; speed?: "fast" | "slow"; percentage?: number; } export function generateSwipeSnippet(options: SwipeOptions): string { const el = buildElementExpr(options.selector); const speed = options.speed ?? "fast"; const percentage = options.percentage ?? 0.75; const normalizedPercentage = Math.round(percentage * 100) / 100; return `await ${el}.swipe('${options.direction}', '${speed}', ${normalizedPercentage});`; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andreahaku/expo_ios_development_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server