@testdriverai/agent 7.9.33-test → 7.9.34-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/skills/testdriver:ai/SKILL.md +204 -0
- package/ai/skills/testdriver:assert/SKILL.md +315 -0
- package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
- package/ai/skills/testdriver:cache/SKILL.md +221 -0
- package/ai/skills/testdriver:caching/SKILL.md +124 -0
- package/ai/skills/testdriver:captcha/SKILL.md +158 -0
- package/ai/skills/testdriver:ci-cd/SKILL.md +602 -0
- package/ai/skills/testdriver:click/SKILL.md +286 -0
- package/ai/skills/testdriver:client/SKILL.md +477 -0
- package/ai/skills/testdriver:customizing-devices/SKILL.md +319 -0
- package/ai/skills/testdriver:dashcam/SKILL.md +451 -0
- package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +415 -0
- package/ai/skills/testdriver:device-config/SKILL.md +317 -0
- package/ai/skills/testdriver:double-click/SKILL.md +102 -0
- package/ai/skills/testdriver:elements/SKILL.md +605 -0
- package/ai/skills/testdriver:enterprise/SKILL.md +7 -0
- package/ai/skills/testdriver:errors/SKILL.md +246 -0
- package/ai/skills/testdriver:events/SKILL.md +356 -0
- package/ai/skills/testdriver:exec/SKILL.md +317 -0
- package/ai/skills/testdriver:find/SKILL.md +860 -0
- package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
- package/ai/skills/testdriver:generating-tests/SKILL.md +36 -0
- package/ai/skills/testdriver:hosted/SKILL.md +156 -0
- package/ai/skills/testdriver:hover/SKILL.md +278 -0
- package/ai/skills/testdriver:locating-elements/SKILL.md +71 -0
- package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
- package/ai/skills/testdriver:mcp/SKILL.md +7 -0
- package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
- package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
- package/ai/skills/testdriver:parse/SKILL.md +236 -0
- package/ai/skills/testdriver:performing-actions/SKILL.md +53 -0
- package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
- package/ai/skills/testdriver:provision/SKILL.md +331 -0
- package/ai/skills/testdriver:quickstart/SKILL.md +172 -0
- package/ai/skills/testdriver:redraw/SKILL.md +214 -0
- package/ai/skills/testdriver:reusable-code/SKILL.md +249 -0
- package/ai/skills/testdriver:right-click/SKILL.md +123 -0
- package/ai/skills/testdriver:running-tests/SKILL.md +185 -0
- package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
- package/ai/skills/testdriver:screenshots/SKILL.md +184 -0
- package/ai/skills/testdriver:scroll/SKILL.md +205 -0
- package/ai/skills/testdriver:secrets/SKILL.md +115 -0
- package/ai/skills/testdriver:self-hosted/SKILL.md +147 -0
- package/ai/skills/testdriver:test-results-json/SKILL.md +257 -0
- package/ai/skills/testdriver:testdriver/SKILL.md +624 -0
- package/ai/skills/testdriver:type/SKILL.md +357 -0
- package/ai/skills/testdriver:variables/SKILL.md +111 -0
- package/ai/skills/testdriver:wait/SKILL.md +50 -0
- package/ai/skills/testdriver:waiting-for-elements/SKILL.md +90 -0
- package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
- package/docs/_data/examples-manifest.json +42 -42
- package/docs/v7/debugging-with-screenshots.mdx +14 -0
- package/docs/v7/examples/ai.mdx +1 -1
- package/docs/v7/examples/assert.mdx +1 -1
- package/docs/v7/examples/chrome-extension.mdx +2 -2
- package/docs/v7/examples/element-not-found.mdx +1 -1
- package/docs/v7/examples/exec-output.mdx +1 -1
- package/docs/v7/examples/exec-pwsh.mdx +1 -1
- package/docs/v7/examples/findall-coffee-icons.mdx +1 -1
- package/docs/v7/examples/focus-window.mdx +1 -1
- package/docs/v7/examples/hover-image.mdx +1 -1
- package/docs/v7/examples/hover-text-with-description.mdx +1 -1
- package/docs/v7/examples/hover-text.mdx +1 -1
- package/docs/v7/examples/installer.mdx +1 -1
- package/docs/v7/examples/launch-vscode-linux.mdx +1 -1
- package/docs/v7/examples/parse.mdx +1 -1
- package/docs/v7/examples/press-keys.mdx +1 -1
- package/docs/v7/examples/prompt.mdx +1 -1
- package/docs/v7/examples/scroll-keyboard.mdx +1 -1
- package/docs/v7/examples/scroll-until-image.mdx +1 -1
- package/docs/v7/examples/scroll.mdx +1 -1
- package/docs/v7/examples/type.mdx +1 -1
- package/docs/v7/examples/windows-installer.mdx +1 -1
- package/docs/v7/find.mdx +33 -0
- package/package.json +1 -1
- package/setup/aws/spawn-runner.sh +24 -3
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testdriver:exec
|
|
3
|
+
description: Execute shell or PowerShell commands in the sandbox
|
|
4
|
+
---
|
|
5
|
+
<!-- Generated from exec.mdx. DO NOT EDIT. -->
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Execute shell commands (Linux) or PowerShell commands (Windows) in the sandbox environment.
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
await testdriver.exec(language, code, timeout, silent)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
<ParamField path="language" type="string" required>
|
|
20
|
+
Language to execute: `'sh'` (Shell/Linux) or `'pwsh'` (PowerShell/Windows)
|
|
21
|
+
</ParamField>
|
|
22
|
+
|
|
23
|
+
<ParamField path="code" type="string" required>
|
|
24
|
+
Code or command to execute
|
|
25
|
+
</ParamField>
|
|
26
|
+
|
|
27
|
+
<ParamField path="timeout" type="number" required>
|
|
28
|
+
Timeout in milliseconds
|
|
29
|
+
</ParamField>
|
|
30
|
+
|
|
31
|
+
<ParamField path="silent" type="boolean" default="false">
|
|
32
|
+
Suppress output if `true`
|
|
33
|
+
</ParamField>
|
|
34
|
+
|
|
35
|
+
## Returns
|
|
36
|
+
|
|
37
|
+
`Promise<string>` - Command output
|
|
38
|
+
|
|
39
|
+
## Shell Execution (Linux)
|
|
40
|
+
|
|
41
|
+
Execute shell commands in the Linux sandbox.
|
|
42
|
+
|
|
43
|
+
### Basic Commands
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// List files
|
|
47
|
+
const files = await testdriver.exec('sh', 'ls -la', 5000);
|
|
48
|
+
|
|
49
|
+
// Check current directory
|
|
50
|
+
const pwd = await testdriver.exec('sh', 'pwd', 5000);
|
|
51
|
+
|
|
52
|
+
// Run a script
|
|
53
|
+
await testdriver.exec('sh', './setup.sh', 60000);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### File Operations
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
// Create a file
|
|
60
|
+
await testdriver.exec('sh', 'echo "Hello World" > test.txt', 5000);
|
|
61
|
+
|
|
62
|
+
// Read a file
|
|
63
|
+
const content = await testdriver.exec('sh', 'cat test.txt', 5000);
|
|
64
|
+
|
|
65
|
+
// Copy files
|
|
66
|
+
await testdriver.exec('sh', 'cp source.txt dest.txt', 5000);
|
|
67
|
+
|
|
68
|
+
// Delete files
|
|
69
|
+
await testdriver.exec('sh', 'rm test.txt', 5000);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## PowerShell Execution (Windows)
|
|
73
|
+
|
|
74
|
+
Execute PowerShell commands in the Windows sandbox.
|
|
75
|
+
|
|
76
|
+
### Software Installation
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
// Install npm package globally
|
|
80
|
+
await testdriver.exec('pwsh', 'npm install -g http-server', 30000);
|
|
81
|
+
|
|
82
|
+
// Install via Chocolatey
|
|
83
|
+
await testdriver.exec('pwsh', 'choco install firefox -y', 60000);
|
|
84
|
+
|
|
85
|
+
// Download and run installer
|
|
86
|
+
await testdriver.exec('pwsh', `
|
|
87
|
+
Invoke-WebRequest -Uri "https://example.com/setup.exe" -OutFile "C:\\setup.exe"
|
|
88
|
+
Start-Process -FilePath "C:\\setup.exe" -ArgumentList "/S" -Wait
|
|
89
|
+
`, 120000);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### File Operations
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// Create a file
|
|
96
|
+
await testdriver.exec('pwsh', `
|
|
97
|
+
Set-Content -Path "C:\\test.txt" -Value "Hello World"
|
|
98
|
+
`, 5000);
|
|
99
|
+
|
|
100
|
+
// Read a file
|
|
101
|
+
const content = await testdriver.exec('pwsh',
|
|
102
|
+
'Get-Content -Path "C:\\test.txt"',
|
|
103
|
+
5000
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Copy files
|
|
107
|
+
await testdriver.exec('pwsh',
|
|
108
|
+
'Copy-Item -Path "C:\\source.txt" -Destination "C:\\dest.txt"',
|
|
109
|
+
5000
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Delete files
|
|
113
|
+
await testdriver.exec('pwsh',
|
|
114
|
+
'Remove-Item -Path "C:\\test.txt"',
|
|
115
|
+
5000
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// List directory
|
|
119
|
+
const files = await testdriver.exec('pwsh',
|
|
120
|
+
'Get-ChildItem -Path "C:\\Users\\testdriver\\Documents"',
|
|
121
|
+
5000
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Process Management
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
// List running processes
|
|
129
|
+
const processes = await testdriver.exec('pwsh', 'Get-Process', 5000);
|
|
130
|
+
|
|
131
|
+
// Start application
|
|
132
|
+
await testdriver.exec('pwsh', `
|
|
133
|
+
Start-Process "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" -ArgumentList "--start-maximized", "https://example.com"
|
|
134
|
+
`, 5000);
|
|
135
|
+
|
|
136
|
+
// Kill a process
|
|
137
|
+
await testdriver.exec('pwsh', 'Stop-Process -Name "chrome" -Force', 5000);
|
|
138
|
+
|
|
139
|
+
// Wait for process
|
|
140
|
+
await testdriver.exec('pwsh', 'Start-Process notepad -Wait', 30000);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Environment Variables
|
|
144
|
+
|
|
145
|
+
```javascript
|
|
146
|
+
// Set environment variable (session)
|
|
147
|
+
await testdriver.exec('pwsh', '$env:MY_VAR = "value"', 5000);
|
|
148
|
+
|
|
149
|
+
// Get environment variable
|
|
150
|
+
const value = await testdriver.exec('pwsh', '$env:MY_VAR', 5000);
|
|
151
|
+
|
|
152
|
+
// Set persistent environment variable
|
|
153
|
+
await testdriver.exec('pwsh', `
|
|
154
|
+
[Environment]::SetEnvironmentVariable("MY_VAR", "value", "User")
|
|
155
|
+
`, 5000);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Network Operations
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
// Test connectivity
|
|
162
|
+
const pingResult = await testdriver.exec('pwsh',
|
|
163
|
+
'Test-NetConnection google.com',
|
|
164
|
+
10000
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
// Download file
|
|
168
|
+
await testdriver.exec('pwsh', `
|
|
169
|
+
Invoke-WebRequest -Uri "https://example.com/file.zip" -OutFile "C:\\Downloads\\file.zip"
|
|
170
|
+
`, 30000);
|
|
171
|
+
|
|
172
|
+
// Check if port is open
|
|
173
|
+
const portOpen = await testdriver.exec('pwsh',
|
|
174
|
+
'Test-NetConnection -ComputerName localhost -Port 3000',
|
|
175
|
+
5000
|
|
176
|
+
);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Silent Execution
|
|
180
|
+
|
|
181
|
+
Suppress output for background operations:
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
// Silent installation
|
|
185
|
+
await testdriver.exec('pwsh', 'npm install -g some-package', 30000, true);
|
|
186
|
+
|
|
187
|
+
// Start background process
|
|
188
|
+
await testdriver.exec('pwsh', 'Start-Process notepad', 5000, true);
|
|
189
|
+
|
|
190
|
+
// Run setup script silently
|
|
191
|
+
await testdriver.exec('pwsh', '.\\setup.ps1', 60000, true);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Best Practices
|
|
195
|
+
|
|
196
|
+
<Check>
|
|
197
|
+
**Use appropriate timeouts**
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
// Quick operations: 5000ms
|
|
201
|
+
await testdriver.exec('sh', 'ls -la', 5000);
|
|
202
|
+
|
|
203
|
+
// Installations: 30000-60000ms
|
|
204
|
+
await testdriver.exec('pwsh', 'npm install -g package', 30000);
|
|
205
|
+
|
|
206
|
+
// Downloads or complex operations: 60000-120000ms
|
|
207
|
+
await testdriver.exec('pwsh', 'Install-Module Something', 120000);
|
|
208
|
+
```
|
|
209
|
+
</Check>
|
|
210
|
+
|
|
211
|
+
<Check>
|
|
212
|
+
**Handle errors gracefully**
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
try {
|
|
216
|
+
await testdriver.exec('pwsh', 'Some-Command', 5000);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
console.error('Command failed:', error.message);
|
|
219
|
+
// Fallback or retry logic
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
</Check>
|
|
223
|
+
|
|
224
|
+
<Check>
|
|
225
|
+
**Use silent mode for background tasks**
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
// Silent install
|
|
229
|
+
await testdriver.exec('pwsh', 'npm install -g tool', 30000, true);
|
|
230
|
+
|
|
231
|
+
// Background service
|
|
232
|
+
await testdriver.exec('pwsh', 'Start-Service MyService', 5000, true);
|
|
233
|
+
```
|
|
234
|
+
</Check>
|
|
235
|
+
|
|
236
|
+
<Warning>
|
|
237
|
+
**Escape strings properly in PowerShell**
|
|
238
|
+
|
|
239
|
+
Use proper escaping for special characters:
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
// Use backticks for newlines
|
|
243
|
+
await testdriver.exec('pwsh', `
|
|
244
|
+
Write-Host "Line 1\`nLine 2"
|
|
245
|
+
`, 5000);
|
|
246
|
+
|
|
247
|
+
// Use single quotes to avoid variable expansion
|
|
248
|
+
await testdriver.exec('pwsh',
|
|
249
|
+
"Write-Host 'Text with $special chars'",
|
|
250
|
+
5000
|
|
251
|
+
);
|
|
252
|
+
```
|
|
253
|
+
</Warning>
|
|
254
|
+
|
|
255
|
+
## Complete Example
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
import { beforeAll, afterAll, describe, it } from 'vitest';
|
|
259
|
+
import TestDriver from 'testdriverai';
|
|
260
|
+
|
|
261
|
+
describe('Code Execution', () => {
|
|
262
|
+
let testdriver;
|
|
263
|
+
|
|
264
|
+
beforeAll(async () => {
|
|
265
|
+
client = new TestDriver(process.env.TD_API_KEY);
|
|
266
|
+
await testdriver.auth();
|
|
267
|
+
await testdriver.connect();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
afterAll(async () => {
|
|
271
|
+
await testdriver.disconnect();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('should execute shell commands on Linux', async () => {
|
|
275
|
+
// List directory
|
|
276
|
+
const files = await testdriver.exec('sh', 'ls -la', 5000);
|
|
277
|
+
console.log('Files:', files);
|
|
278
|
+
|
|
279
|
+
// Create a file
|
|
280
|
+
await testdriver.exec('sh', 'echo "Hello World" > test.txt', 5000);
|
|
281
|
+
|
|
282
|
+
// Read the file
|
|
283
|
+
const content = await testdriver.exec('sh', 'cat test.txt', 5000);
|
|
284
|
+
expect(content).toContain('Hello World');
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('should install and use tools on Windows', async () => {
|
|
288
|
+
// Install tool
|
|
289
|
+
await testdriver.exec('pwsh', 'npm install -g http-server', 30000, true);
|
|
290
|
+
|
|
291
|
+
// Create HTML file
|
|
292
|
+
await testdriver.exec('pwsh', `
|
|
293
|
+
Set-Content -Path "C:\\index.html" -Value "<h1>Test Page</h1>"
|
|
294
|
+
`, 5000);
|
|
295
|
+
|
|
296
|
+
// Start server in background
|
|
297
|
+
await testdriver.exec('pwsh', `
|
|
298
|
+
Start-Process pwsh -ArgumentList "-Command", "http-server C:\\ -p 8080"
|
|
299
|
+
`, 5000, true);
|
|
300
|
+
|
|
301
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
302
|
+
|
|
303
|
+
// Launch browser
|
|
304
|
+
await testdriver.exec('pwsh', `
|
|
305
|
+
Start-Process chrome -ArgumentList "http://localhost:8080"
|
|
306
|
+
`, 5000);
|
|
307
|
+
|
|
308
|
+
await testdriver.focusApplication('Google Chrome');
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Related Methods
|
|
314
|
+
|
|
315
|
+
- [`focusApplication()`](/v7/focus-application) - Focus apps before exec
|
|
316
|
+
- [`find()`](/v7/find) - Locate elements visually
|
|
317
|
+
- [`type()`](/v7/type) - Type text into inputs
|