Skip to content

Commit 78a8cfc

Browse files
authored
Add activate_app interaction (#7)
* Add activate_app interaction * Update README * Ignore Documents json in prettier tests
1 parent 74514b9 commit 78a8cfc

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ Thumbs.db
2424

2525
# Generated files
2626
*.d.ts
27+
28+
# Documents
29+
src/tools/documentation/uploads/documents.json

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ Upload a mobile app to LambdaTest cloud storage for testing.
136136
- `appPath`: Local path to the app file (APK/IPA)
137137
- `appName`: Optional custom name for the app
138138

139+
#### `activate_app`
140+
141+
Activate the app passed as input
142+
143+
- **Parameters**:
144+
- `id`: Bundle ID or app-packge
145+
139146
### Element Interaction
140147

141148
#### `generate_locators`

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import setValue from './interactions/setValue.js';
1111
import getText from './interactions/getText.js';
1212
import screenshot from './interactions/screenshot.js';
1313
import answerAppium from './answerAppium.js';
14+
import activateApp from './interactions/activateApp.js';
1415

1516
export default function registerTools(server: FastMCP): void {
1617
selectPlatform(server);
@@ -25,6 +26,7 @@ export default function registerTools(server: FastMCP): void {
2526
setValue(server);
2627
getText(server);
2728
screenshot(server);
29+
activateApp(server);
2830

2931
generateTest(server);
3032
console.log('All tools registered');
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { FastMCP } from 'fastmcp/dist/FastMCP.js';
2+
import { getDriver } from '../sessionStore.js';
3+
import { z } from 'zod';
4+
5+
export default function activateApp(server: FastMCP): void {
6+
const activateAppSchema = z.object({
7+
id: z.string().describe('The app id'),
8+
});
9+
10+
server.addTool({
11+
name: 'activate_app',
12+
description: 'Activate app by id',
13+
parameters: activateAppSchema,
14+
annotations: {
15+
readOnlyHint: false,
16+
openWorldHint: false,
17+
},
18+
execute: async (args: { id: string }, context: any): Promise<any> => {
19+
const driver = getDriver();
20+
if (!driver) {
21+
throw new Error('No driver found');
22+
}
23+
24+
try {
25+
await driver.activateApp(args.id);
26+
return {
27+
content: [
28+
{
29+
type: 'text',
30+
text: `App ${args.id} activated correctly.`,
31+
},
32+
],
33+
};
34+
} catch (err: any) {
35+
return {
36+
content: [
37+
{
38+
type: 'text',
39+
text: `Error activating the app ${args.id}: ${err.toString()}`,
40+
},
41+
],
42+
};
43+
}
44+
},
45+
});
46+
}

0 commit comments

Comments
 (0)