diff --git a/.prettierignore b/.prettierignore index d3f3294..3a66a2a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -24,3 +24,6 @@ Thumbs.db # Generated files *.d.ts + +# Documents +src/tools/documentation/uploads/documents.json diff --git a/README.md b/README.md index aafe78a..cd5b6b9 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,13 @@ Upload a mobile app to LambdaTest cloud storage for testing. - `appPath`: Local path to the app file (APK/IPA) - `appName`: Optional custom name for the app +#### `activate_app` + +Activate the app passed as input + +- **Parameters**: + - `id`: Bundle ID or app-packge + ### Element Interaction #### `generate_locators` diff --git a/src/tools/index.ts b/src/tools/index.ts index 0f96c78..c2cf31a 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -11,6 +11,7 @@ import setValue from './interactions/setValue.js'; import getText from './interactions/getText.js'; import screenshot from './interactions/screenshot.js'; import answerAppium from './answerAppium.js'; +import activateApp from './interactions/activateApp.js'; export default function registerTools(server: FastMCP): void { selectPlatform(server); @@ -25,6 +26,7 @@ export default function registerTools(server: FastMCP): void { setValue(server); getText(server); screenshot(server); + activateApp(server); generateTest(server); console.log('All tools registered'); diff --git a/src/tools/interactions/activateApp.ts b/src/tools/interactions/activateApp.ts new file mode 100644 index 0000000..0151396 --- /dev/null +++ b/src/tools/interactions/activateApp.ts @@ -0,0 +1,46 @@ +import { FastMCP } from 'fastmcp/dist/FastMCP.js'; +import { getDriver } from '../sessionStore.js'; +import { z } from 'zod'; + +export default function activateApp(server: FastMCP): void { + const activateAppSchema = z.object({ + id: z.string().describe('The app id'), + }); + + server.addTool({ + name: 'activate_app', + description: 'Activate app by id', + parameters: activateAppSchema, + annotations: { + readOnlyHint: false, + openWorldHint: false, + }, + execute: async (args: { id: string }, context: any): Promise => { + const driver = getDriver(); + if (!driver) { + throw new Error('No driver found'); + } + + try { + await driver.activateApp(args.id); + return { + content: [ + { + type: 'text', + text: `App ${args.id} activated correctly.`, + }, + ], + }; + } catch (err: any) { + return { + content: [ + { + type: 'text', + text: `Error activating the app ${args.id}: ${err.toString()}`, + }, + ], + }; + } + }, + }); +}