Skip to main content
Glama
andreahaku
by andreahaku

ui.long_press

Perform long press interactions on iOS Simulator UI elements for React Native/Expo app testing. Simulate user gestures by pressing elements for specified durations to test touch interactions and accessibility features.

Instructions

Long press on an element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesElement selector.
durationNoPress duration in milliseconds.

Implementation Reference

  • Primary handler and registration for the 'ui.long_press' MCP tool. Generates a Detox action snippet and executes it via runDetoxAction.
    server.tool( "ui.long_press", "Long press on an element", UiLongPressInputSchema.shape, async (args) => { try { const snippet = generateLongPressSnippet({ selector: args.selector, duration: args.duration, }); const result = await runDetoxAction({ actionName: `longPress:${describeSelector(args.selector)}`, actionSnippet: snippet, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; } catch (error) { return handleToolError(error); } } );
  • Zod input schema for ui.long_press tool parameters: selector and optional duration.
    export const UiLongPressInputSchema = z.object({ selector: SelectorSchema.describe("Element selector."), duration: z.number().optional().default(1000).describe("Press duration in milliseconds."), });
  • Helper function that generates the Detox JavaScript snippet for performing a long press action on an element.
    export interface LongPressOptions { selector: Selector; duration?: number; } export function generateLongPressSnippet(options: LongPressOptions): string { const el = buildElementExpr(options.selector); const duration = options.duration ?? 1000; return `await ${el}.longPress(${duration});`; }
  • Helper to build Detox element expression from MCP selector, used in snippet generation.
    export function buildElementExpr(selector: Selector, index?: number): string { const matcher = selectorToDetoxExpr(selector); if (index !== undefined) { return `element(${matcher}).atIndex(${index})`; } return `element(${matcher})`; }
  • Helper to create a human-readable description of the selector for action names.
    export function describeSelector(selector: Selector): string { return `${selector.by}="${selector.value}"`; }

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