Skip to main content
Glama
andreahaku
by andreahaku

ui.scroll

Scroll within scrollable elements in iOS Simulator for React Native/Expo apps. Specify direction and element selector to navigate UI during testing.

Instructions

Scroll within a scrollable element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesScrollable element selector.
directionYesScroll direction.
amountNoScroll amount in pixels.

Implementation Reference

  • Registration of the 'ui.scroll' MCP tool, including the inline handler function that generates a Detox scroll code snippet using generateScrollSnippet and executes it via runDetoxAction.
    server.tool( "ui.scroll", "Scroll within a scrollable element", UiScrollInputSchema.shape, async (args) => { try { const snippet = generateScrollSnippet({ selector: args.selector, direction: args.direction, amount: args.amount, }); const result = await runDetoxAction({ actionName: `scroll:${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); } } );
  • Handler function for 'ui.scroll' tool: validates input via schema, generates Detox scroll snippet, executes via runDetoxAction, returns result or error.
    async (args) => { try { const snippet = generateScrollSnippet({ selector: args.selector, direction: args.direction, amount: args.amount, }); const result = await runDetoxAction({ actionName: `scroll:${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 input schema for 'ui.scroll' tool defining selector, direction (up/down/left/right), and optional scroll amount (pixels).
    export const UiScrollInputSchema = z.object({ selector: SelectorSchema.describe("Scrollable element selector."), direction: DirectionSchema.describe("Scroll direction."), amount: z.number().optional().default(200).describe("Scroll amount in pixels."), });
  • Helper function generateScrollSnippet that creates the Detox JavaScript code for scrolling a scrollable element by amount pixels in the specified direction from relative start position.
    export interface ScrollOptions { selector: Selector; direction: Direction; amount?: number; startPositionX?: number; startPositionY?: number; } export function generateScrollSnippet(options: ScrollOptions): string { const el = buildElementExpr(options.selector); const amount = options.amount ?? 200; const startX = options.startPositionX ?? 0.5; const startY = options.startPositionY ?? 0.5; return `await ${el}.scroll(${amount}, '${options.direction}', ${startX}, ${startY});`; }

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