testdriverai 7.2.11 → 7.2.12

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.
@@ -0,0 +1,320 @@
1
+ ---
2
+ title: "Configuring the Device"
3
+ description: "Launch browsers, desktop apps, and extensions in your TestDriver sandbox"
4
+ icon: "wrench"
5
+ ---
6
+
7
+ Provision methods are the starting point for most tests. They launch applications in your sandbox and prepare the environment for testing.
8
+
9
+ ## Chrome Browser
10
+
11
+ The most common starting point for web testing. Launches Chrome browser and navigates to a URL.
12
+
13
+ ```javascript
14
+ await testdriver.provision.chrome({
15
+ url: 'https://example.com',
16
+ });
17
+ ```
18
+
19
+ ### Options
20
+
21
+ | Option | Type | Default | Description |
22
+ |--------|------|---------|-------------|
23
+ | `url` | string | `'http://testdriver-sandbox.vercel.app/'` | URL to navigate to |
24
+ | `maximized` | boolean | `true` | Start browser maximized |
25
+ | `guest` | boolean | `false` | Use guest mode (no profile) |
26
+
27
+ ### Example: Basic Web Test
28
+
29
+ ```javascript
30
+ import { describe, expect, it } from "vitest";
31
+ import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
32
+
33
+ describe("Login Flow", () => {
34
+ it("should log in successfully", async (context) => {
35
+ const testdriver = TestDriver(context, { newSandbox: true });
36
+
37
+ await testdriver.provision.chrome({
38
+ url: 'https://myapp.com/login',
39
+ });
40
+
41
+ await testdriver.find("Email input").click();
42
+ await testdriver.type("user@example.com");
43
+
44
+ await testdriver.find("Password input").click();
45
+ await testdriver.type("password123");
46
+
47
+ await testdriver.find("Sign In button").click();
48
+
49
+ const result = await testdriver.assert("the dashboard is visible");
50
+ expect(result).toBeTruthy();
51
+ });
52
+ });
53
+ ```
54
+
55
+ <Info>
56
+ `provision.chrome()` automatically starts Dashcam recording and waits for Chrome to be ready before returning.
57
+ </Info>
58
+
59
+ ---
60
+
61
+ ## Chrome Extensions
62
+
63
+ Launch Chrome with a custom extension loaded. Supports both local extensions and Chrome Web Store extensions.
64
+
65
+ ### Load from Local Path
66
+
67
+ Clone or create an extension locally, then load it:
68
+
69
+ ```javascript
70
+ // First, get the extension onto the sandbox
71
+ await testdriver.exec(
72
+ 'sh',
73
+ 'git clone https://github.com/user/my-extension.git /tmp/my-extension',
74
+ 60000
75
+ );
76
+
77
+ // Launch Chrome with the extension
78
+ await testdriver.provision.chromeExtension({
79
+ extensionPath: '/tmp/my-extension',
80
+ url: 'https://example.com'
81
+ });
82
+ ```
83
+
84
+ ### Load from Chrome Web Store
85
+
86
+ Load any published extension by its Chrome Web Store ID:
87
+
88
+ ```javascript
89
+ await testdriver.provision.chromeExtension({
90
+ extensionId: 'cjpalhdlnbpafiamejdnhcphjbkeiagm', // uBlock Origin
91
+ url: 'https://example.com'
92
+ });
93
+ ```
94
+
95
+ <Tip>
96
+ Find the extension ID in the Chrome Web Store URL. For example, `https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm` → ID is `cjpalhdlnbpafiamejdnhcphjbkeiagm`
97
+ </Tip>
98
+
99
+ ### Options
100
+
101
+ | Option | Type | Default | Description |
102
+ |--------|------|---------|-------------|
103
+ | `extensionPath` | string | - | Local path to unpacked extension directory |
104
+ | `extensionId` | string | - | Chrome Web Store extension ID |
105
+ | `url` | string | - | URL to navigate to after launch |
106
+ | `maximized` | boolean | `true` | Start browser maximized |
107
+
108
+ <Warning>
109
+ You must provide either `extensionPath` or `extensionId`, but not both.
110
+ </Warning>
111
+
112
+ ### Example: Testing a Chrome Extension
113
+
114
+ ```javascript
115
+ import { describe, expect, it } from "vitest";
116
+ import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
117
+
118
+ describe("Chrome Extension Test", () => {
119
+ it("should load and interact with extension", async (context) => {
120
+ const testdriver = TestDriver(context, { newSandbox: true });
121
+
122
+ // Clone extension from GitHub
123
+ await testdriver.ready();
124
+ await testdriver.exec(
125
+ 'sh',
126
+ 'git clone https://github.com/user/my-extension.git /tmp/my-extension',
127
+ 60000,
128
+ true
129
+ );
130
+
131
+ // Launch Chrome with extension loaded
132
+ await testdriver.provision.chromeExtension({
133
+ extensionPath: '/tmp/my-extension',
134
+ url: 'https://testdriver.ai'
135
+ });
136
+
137
+ // Click extensions puzzle icon
138
+ const extensionsButton = await testdriver.find("puzzle-shaped icon in Chrome toolbar");
139
+ await extensionsButton.click();
140
+
141
+ // Interact with your extension
142
+ const myExtension = await testdriver.find("My Extension in the dropdown");
143
+ await myExtension.click();
144
+
145
+ const result = await testdriver.assert("extension popup is visible");
146
+ expect(result).toBeTruthy();
147
+ });
148
+ });
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Desktop Apps
154
+
155
+ Download and install desktop applications. Supports `.deb`, `.rpm`, `.msi`, `.exe`, `.AppImage`, `.dmg`, `.pkg`, and shell scripts.
156
+
157
+ ```javascript
158
+ const filePath = await testdriver.provision.installer({
159
+ url: 'https://example.com/app.deb',
160
+ appName: 'MyApp', // Focus this app after install
161
+ launch: true, // Auto-launch after install
162
+ });
163
+ ```
164
+
165
+ ### Options
166
+
167
+ | Option | Type | Default | Description |
168
+ |--------|------|---------|-------------|
169
+ | `url` | string | **required** | URL to download the installer from |
170
+ | `filename` | string | auto-detected | Filename to save as |
171
+ | `appName` | string | - | Application name to focus after install |
172
+ | `launch` | boolean | `true` | Launch the app after installation |
173
+
174
+ ### Supported File Types
175
+
176
+ | Extension | OS | Install Method |
177
+ |-----------|-----|----------------|
178
+ | `.deb` | Linux | `dpkg -i` + `apt-get install -f` |
179
+ | `.rpm` | Linux | `rpm -i` |
180
+ | `.AppImage` | Linux | `chmod +x` |
181
+ | `.sh` | Linux | `chmod +x` + execute |
182
+ | `.msi` | Windows | `msiexec /i /quiet` |
183
+ | `.exe` | Windows | Silent install (`/S`) |
184
+ | `.dmg` | macOS | Mount + copy to Applications |
185
+ | `.pkg` | macOS | `installer -pkg` |
186
+
187
+ ### Example: Install and Test a Desktop App
188
+
189
+ ```javascript
190
+ import { describe, expect, it } from "vitest";
191
+ import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
192
+
193
+ describe("Desktop App Test", () => {
194
+ it("should install and launch app", async (context) => {
195
+ const testdriver = TestDriver(context, { newSandbox: true });
196
+
197
+ // Download and install
198
+ const installerPath = await testdriver.provision.installer({
199
+ url: 'https://github.com/sharkdp/bat/releases/download/v0.24.0/bat_0.24.0_amd64.deb',
200
+ });
201
+
202
+ // Verify installation
203
+ const output = await testdriver.exec('sh', 'bat --version', 5000);
204
+ expect(output).toContain('bat');
205
+ });
206
+ });
207
+ ```
208
+
209
+ ### Example: Windows Installer
210
+
211
+ ```javascript
212
+ import { describe, expect, it } from "vitest";
213
+ import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
214
+
215
+ describe("Windows App Test", () => {
216
+ it("should install on Windows", async (context) => {
217
+ const testdriver = TestDriver(context, {
218
+ newSandbox: true,
219
+ os: 'windows'
220
+ });
221
+
222
+ // Download MSI installer
223
+ const installerPath = await testdriver.provision.installer({
224
+ url: 'https://example.com/app.msi',
225
+ launch: false, // Don't auto-launch
226
+ });
227
+
228
+ // Custom installation if needed
229
+ await testdriver.exec(
230
+ 'pwsh',
231
+ `Start-Process msiexec.exe -ArgumentList "/i", "${installerPath}", "/qn" -Wait`,
232
+ 120000
233
+ );
234
+
235
+ // Verify installation
236
+ const result = await testdriver.assert("application is installed");
237
+ expect(result).toBeTruthy();
238
+ });
239
+ });
240
+ ```
241
+
242
+ ### Manual Installation
243
+
244
+ Set `launch: false` to download without auto-installing:
245
+
246
+ ```javascript
247
+ const filePath = await testdriver.provision.installer({
248
+ url: 'https://example.com/custom-script.sh',
249
+ launch: false,
250
+ });
251
+
252
+ // Run custom install commands
253
+ await testdriver.exec('sh', `chmod +x "${filePath}"`, 5000);
254
+ await testdriver.exec('sh', `"${filePath}" --custom-flag`, 60000);
255
+ ```
256
+
257
+ ---
258
+
259
+ ## VS Code
260
+
261
+ Launch Visual Studio Code with optional workspace and extensions.
262
+
263
+ ```javascript
264
+ await testdriver.provision.vscode({
265
+ workspace: '/home/testdriver/my-project',
266
+ extensions: ['ms-python.python', 'esbenp.prettier-vscode'],
267
+ });
268
+ ```
269
+
270
+ ### Options
271
+
272
+ | Option | Type | Default | Description |
273
+ |--------|------|---------|-------------|
274
+ | `workspace` | string | - | Workspace folder to open |
275
+ | `extensions` | string[] | `[]` | Extensions to install (by ID) |
276
+
277
+ ### Example: VS Code Extension Test
278
+
279
+ ```javascript
280
+ import { describe, expect, it } from "vitest";
281
+ import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
282
+
283
+ describe("VS Code Test", () => {
284
+ it("should open workspace with extensions", async (context) => {
285
+ const testdriver = TestDriver(context, { newSandbox: true });
286
+
287
+ // Create a test project
288
+ await testdriver.ready();
289
+ await testdriver.exec('sh', 'mkdir -p /tmp/test-project && echo "print(1)" > /tmp/test-project/test.py', 10000);
290
+
291
+ // Launch VS Code
292
+ await testdriver.provision.vscode({
293
+ workspace: '/tmp/test-project',
294
+ extensions: ['ms-python.python'],
295
+ });
296
+
297
+ // Verify VS Code is ready
298
+ const result = await testdriver.assert("VS Code is open with the project");
299
+ expect(result).toBeTruthy();
300
+
301
+ // Open the Python file
302
+ await testdriver.find("test.py in the explorer").click();
303
+ });
304
+ });
305
+ ```
306
+
307
+ ---
308
+
309
+ ## Choosing the Right Provision Method
310
+
311
+ | Use Case | Method |
312
+ |----------|--------|
313
+ | Testing a website | `provision.chrome` |
314
+ | Testing a Chrome extension | `provision.chromeExtension` |
315
+ | Testing a desktop app (needs installation) | `provision.installer` |
316
+ | Testing VS Code or VS Code extensions | `provision.vscode` |
317
+
318
+ <Tip>
319
+ All provision methods automatically start Dashcam recording and wait for the application to be ready before returning. You don't need to call `dashcam.start()` manually.
320
+ </Tip>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.2.11",
3
+ "version": "7.2.12",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "exports": {