testdriverai 7.3.11 → 7.3.13

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.
Files changed (133) hide show
  1. package/.github/skills/testdriver:ai/SKILL.md +204 -0
  2. package/.github/skills/testdriver:assert/SKILL.md +284 -0
  3. package/.github/skills/testdriver:aws-setup/SKILL.md +515 -0
  4. package/.github/skills/testdriver:caching/SKILL.md +124 -0
  5. package/.github/skills/testdriver:captcha/SKILL.md +159 -0
  6. package/.github/skills/testdriver:ci-cd/SKILL.md +602 -0
  7. package/.github/skills/testdriver:click/SKILL.md +286 -0
  8. package/.github/skills/testdriver:client/SKILL.md +339 -0
  9. package/.github/skills/testdriver:cloud/SKILL.md +119 -0
  10. package/.github/skills/testdriver:customizing-devices/SKILL.md +153 -0
  11. package/.github/skills/testdriver:dashcam/SKILL.md +418 -0
  12. package/.github/skills/testdriver:debugging-with-screenshots/SKILL.md +271 -0
  13. package/.github/skills/testdriver:device-config/SKILL.md +317 -0
  14. package/.github/skills/testdriver:double-click/SKILL.md +102 -0
  15. package/.github/skills/testdriver:elements/SKILL.md +605 -0
  16. package/.github/skills/testdriver:enterprise/SKILL.md +114 -0
  17. package/.github/skills/testdriver:examples/SKILL.md +7 -0
  18. package/.github/skills/testdriver:exec/SKILL.md +345 -0
  19. package/.github/skills/testdriver:find/SKILL.md +721 -0
  20. package/.github/skills/testdriver:focus-application/SKILL.md +293 -0
  21. package/.github/skills/testdriver:generating-tests/SKILL.md +36 -0
  22. package/.github/skills/testdriver:hover/SKILL.md +278 -0
  23. package/.github/skills/testdriver:locating-elements/SKILL.md +71 -0
  24. package/.github/skills/testdriver:making-assertions/SKILL.md +32 -0
  25. package/.github/skills/testdriver:mcp-workflow/SKILL.md +410 -0
  26. package/.github/skills/testdriver:mouse-down/SKILL.md +161 -0
  27. package/.github/skills/testdriver:mouse-up/SKILL.md +164 -0
  28. package/.github/skills/testdriver:performing-actions/SKILL.md +51 -0
  29. package/.github/skills/testdriver:press-keys/SKILL.md +348 -0
  30. package/.github/skills/testdriver:quickstart/SKILL.md +161 -0
  31. package/.github/skills/testdriver:reusable-code/SKILL.md +240 -0
  32. package/.github/skills/testdriver:right-click/SKILL.md +123 -0
  33. package/.github/skills/testdriver:running-tests/SKILL.md +181 -0
  34. package/.github/skills/testdriver:screenshot/SKILL.md +167 -0
  35. package/.github/skills/testdriver:scroll/SKILL.md +299 -0
  36. package/.github/skills/testdriver:secrets/SKILL.md +115 -0
  37. package/.github/skills/testdriver:self-hosted/SKILL.md +65 -0
  38. package/.github/skills/testdriver:test-writer/SKILL.md +451 -0
  39. package/.github/skills/testdriver:testdriver/SKILL.md +523 -0
  40. package/.github/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
  41. package/.github/skills/testdriver:type/SKILL.md +357 -0
  42. package/.github/skills/testdriver:variables/SKILL.md +111 -0
  43. package/.github/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
  44. package/.github/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
  45. package/.github/workflows/acceptance-windows-scheduled.yaml +6 -1
  46. package/.github/workflows/acceptance.yaml +0 -36
  47. package/.github/workflows/update-examples.yaml +53 -0
  48. package/CHANGELOG.md +8 -0
  49. package/agent/events.js +1 -0
  50. package/agent/index.js +8 -0
  51. package/agent/lib/commands.js +48 -29
  52. package/agent/lib/redraw.js +3 -1
  53. package/agent/lib/sandbox.js +166 -14
  54. package/agent/lib/sdk.js +142 -3
  55. package/agent/lib/system.js +4 -6
  56. package/ai/skills/testdriver:ai/SKILL.md +204 -0
  57. package/ai/skills/testdriver:assert/SKILL.md +315 -0
  58. package/ai/skills/testdriver:aws-setup/SKILL.md +448 -0
  59. package/ai/skills/testdriver:caching/SKILL.md +124 -0
  60. package/ai/skills/testdriver:captcha/SKILL.md +159 -0
  61. package/ai/skills/testdriver:ci-cd/SKILL.md +602 -0
  62. package/ai/skills/testdriver:click/SKILL.md +286 -0
  63. package/ai/skills/testdriver:client/SKILL.md +372 -0
  64. package/ai/skills/testdriver:cloud/SKILL.md +119 -0
  65. package/ai/skills/testdriver:customizing-devices/SKILL.md +153 -0
  66. package/ai/skills/testdriver:dashcam/SKILL.md +418 -0
  67. package/ai/skills/testdriver:debugging-with-screenshots/SKILL.md +401 -0
  68. package/ai/skills/testdriver:device-config/SKILL.md +317 -0
  69. package/ai/skills/testdriver:double-click/SKILL.md +102 -0
  70. package/ai/skills/testdriver:elements/SKILL.md +605 -0
  71. package/ai/skills/testdriver:enterprise/SKILL.md +114 -0
  72. package/ai/skills/testdriver:examples/SKILL.md +7 -0
  73. package/ai/skills/testdriver:exec/SKILL.md +345 -0
  74. package/ai/skills/testdriver:find/SKILL.md +745 -0
  75. package/ai/skills/testdriver:focus-application/SKILL.md +293 -0
  76. package/ai/skills/testdriver:generating-tests/SKILL.md +36 -0
  77. package/ai/skills/testdriver:hover/SKILL.md +278 -0
  78. package/ai/skills/testdriver:locating-elements/SKILL.md +71 -0
  79. package/ai/skills/testdriver:making-assertions/SKILL.md +32 -0
  80. package/ai/skills/testdriver:mcp-workflow/SKILL.md +410 -0
  81. package/ai/skills/testdriver:mouse-down/SKILL.md +161 -0
  82. package/ai/skills/testdriver:mouse-up/SKILL.md +164 -0
  83. package/ai/skills/testdriver:ocr/SKILL.md +235 -0
  84. package/ai/skills/testdriver:performing-actions/SKILL.md +51 -0
  85. package/ai/skills/testdriver:press-keys/SKILL.md +348 -0
  86. package/ai/skills/testdriver:quickstart/SKILL.md +146 -0
  87. package/ai/skills/testdriver:reusable-code/SKILL.md +240 -0
  88. package/ai/skills/testdriver:right-click/SKILL.md +123 -0
  89. package/ai/skills/testdriver:running-tests/SKILL.md +185 -0
  90. package/ai/skills/testdriver:screenshot/SKILL.md +248 -0
  91. package/ai/skills/testdriver:scroll/SKILL.md +335 -0
  92. package/ai/skills/testdriver:secrets/SKILL.md +115 -0
  93. package/ai/skills/testdriver:self-hosted/SKILL.md +65 -0
  94. package/ai/skills/testdriver:test-writer/SKILL.md +451 -0
  95. package/ai/skills/testdriver:testdriver/SKILL.md +631 -0
  96. package/ai/skills/testdriver:testdriver-mechanic/SKILL.md +165 -0
  97. package/ai/skills/testdriver:type/SKILL.md +357 -0
  98. package/ai/skills/testdriver:variables/SKILL.md +111 -0
  99. package/ai/skills/testdriver:waiting-for-elements/SKILL.md +66 -0
  100. package/ai/skills/testdriver:what-is-testdriver/SKILL.md +54 -0
  101. package/debugger/index.html +12 -2
  102. package/docs/v7/examples/scroll-keyboard.mdx +1 -1
  103. package/docs/v7/find.mdx +1 -0
  104. package/examples/config.mjs +1 -1
  105. package/examples/findall-coffee-icons.test.mjs +42 -0
  106. package/examples/flake-diffthreshold-001.test.mjs +9 -0
  107. package/examples/flake-diffthreshold-01.test.mjs +9 -0
  108. package/examples/flake-diffthreshold-05.test.mjs +9 -0
  109. package/examples/{z_flake-noredraw-cache.test.mjs → flake-noredraw-cache.test.mjs} +2 -2
  110. package/examples/{z_flake-noredraw-nocache.test.mjs → flake-noredraw-nocache.test.mjs} +2 -2
  111. package/examples/{z_flake-redraw-cache.test.mjs → flake-redraw-cache.test.mjs} +2 -2
  112. package/examples/{z_flake-redraw-nocache.test.mjs → flake-redraw-nocache.test.mjs} +2 -2
  113. package/examples/flake-rocket-match.test.mjs +30 -0
  114. package/examples/{z_flake-shared.mjs → flake-shared.mjs} +2 -2
  115. package/examples/parse.test.mjs +19 -0
  116. package/examples/scroll-keyboard.test.mjs +1 -1
  117. package/interfaces/cli/lib/base.js +6 -0
  118. package/interfaces/logger.js +51 -13
  119. package/interfaces/vitest-plugin.mjs +137 -0
  120. package/lib/core/index.d.ts +22 -0
  121. package/lib/init-project.js +105 -6
  122. package/lib/vitest/hooks.mjs +2 -5
  123. package/lib/vitest/setup-disable-defender.mjs +52 -0
  124. package/package.json +2 -1
  125. package/sdk-log-formatter.js +90 -0
  126. package/sdk.d.ts +88 -51
  127. package/sdk.js +128 -21
  128. package/setup/aws/disable-defender.sh +42 -0
  129. package/vitest.config.mjs +1 -3
  130. package/examples/z_flake-diffthreshold-001.test.mjs +0 -9
  131. package/examples/z_flake-diffthreshold-01.test.mjs +0 -9
  132. package/examples/z_flake-diffthreshold-05.test.mjs +0 -9
  133. /package/{examples → manual}/captcha-api.test.mjs +0 -0
@@ -0,0 +1,357 @@
1
+ ---
2
+ name: testdriver:type
3
+ description: Type text into focused input fields
4
+ ---
5
+ <!-- Generated from type.mdx. DO NOT EDIT. -->
6
+
7
+ ## Overview
8
+
9
+ Type text or numbers into the currently focused input field with optional delay between keystrokes.
10
+
11
+ ## Syntax
12
+
13
+ ```javascript
14
+ await testdriver.type(text, options)
15
+ ```
16
+
17
+ ## Parameters
18
+
19
+ <ParamField path="text" type="string | number" required>
20
+ Text to type (can be a string or number)
21
+ </ParamField>
22
+
23
+ <ParamField path="options" type="object | number">
24
+ Typing options (or legacy delay number)
25
+
26
+ <Expandable title="properties">
27
+ <ParamField path="delay" type="number" default={250}>
28
+ Delay between keystrokes in milliseconds
29
+ </ParamField>
30
+
31
+ <ParamField path="secret" type="boolean" default={false}>
32
+ If `true`, treats text as sensitive data (won't be logged or stored in debug info/dashcam)
33
+ </ParamField>
34
+ </Expandable>
35
+ </ParamField>
36
+
37
+ ## Returns
38
+
39
+ `Promise<void>`
40
+
41
+ ## Examples
42
+
43
+ ### Basic Typing
44
+
45
+ ```javascript
46
+ // Type text
47
+ await testdriver.type('hello@example.com');
48
+
49
+ // Type numbers
50
+ await testdriver.type(12345);
51
+
52
+ // Type with custom delay (legacy syntax)
53
+ await testdriver.type('slow typing', 500); // 500ms between each character
54
+
55
+ // Type with options object
56
+ await testdriver.type('text', { delay: 500 });
57
+ ```
58
+
59
+ ### Password/Secret Handling
60
+
61
+ ```javascript
62
+ // ✅ SECURE - Mark as secret to prevent logging
63
+ const passwordField = await testdriver.find('password input');
64
+ await passwordField.click();
65
+ await testdriver.type('MySecureP@ssw0rd', { secret: true });
66
+ // Password NOT logged in dashcam or debug output
67
+
68
+ // ❌ INSECURE - Password will be logged
69
+ await testdriver.type('MySecureP@ssw0rd');
70
+ // Password appears in logs, dashcam replay, and debug info
71
+
72
+ // Use secret for any sensitive data
73
+ await testdriver.find('api key input').click();
74
+ await testdriver.type('sk-1234567890abcdef', { secret: true });
75
+
76
+ await testdriver.find('credit card input').click();
77
+ await testdriver.type('4111111111111111', { secret: true });
78
+ ```
79
+
80
+ <Warning>
81
+ **Always use `secret: true` for passwords and sensitive data!**
82
+
83
+ Without this option, typed text appears in:
84
+ - Dashcam video replays
85
+ - TestDriver logs
86
+ - Debug screenshots
87
+ - Error messages
88
+ </Warning>
89
+
90
+ ### Form Filling
91
+
92
+ ```javascript
93
+ // Focus field and type
94
+ const emailField = await testdriver.find('email input');
95
+ await emailField.click();
96
+ await testdriver.type('user@example.com');
97
+
98
+ // Tab to next field and type
99
+ await testdriver.pressKeys(['tab']);
100
+ await testdriver.type('John Doe');
101
+
102
+ // Type password securely
103
+ await testdriver.pressKeys(['tab']);
104
+ await testdriver.type('MySecureP@ssw0rd', { secret: true });
105
+ ```
106
+
107
+ ### Clearing and Replacing Text
108
+
109
+ ```javascript
110
+ const searchBox = await testdriver.find('search input');
111
+ await searchBox.click();
112
+
113
+ // Clear existing text
114
+ await testdriver.pressKeys(['ctrl', 'a']); // Select all
115
+ await testdriver.type('new search query');
116
+ ```
117
+
118
+ ## Best Practices
119
+
120
+ <Check>
121
+ **Focus the field first**
122
+
123
+ Always click the input field or navigate to it before typing:
124
+
125
+ ```javascript
126
+ const input = await testdriver.find('username input');
127
+ await input.click();
128
+ await testdriver.type('testuser');
129
+ ```
130
+ </Check>
131
+
132
+ <Check>
133
+ **Use Tab for navigation**
134
+
135
+ Navigate between fields using Tab instead of clicking each one:
136
+
137
+ ```javascript
138
+ const firstField = await testdriver.find('first name');
139
+ await firstField.click();
140
+ await testdriver.type('John');
141
+
142
+ await testdriver.pressKeys(['tab']);
143
+ await testdriver.type('Doe');
144
+
145
+ await testdriver.pressKeys(['tab']);
146
+ await testdriver.type('john@example.com');
147
+ ```
148
+ </Check>
149
+
150
+ <Check>
151
+ **Clear fields before typing**
152
+
153
+ Clear existing content to avoid appending:
154
+
155
+ ```javascript
156
+ const input = await testdriver.find('search field');
157
+ await input.click();
158
+ await testdriver.pressKeys(['ctrl', 'a']); // Select all
159
+ await testdriver.type('new search');
160
+ ```
161
+ </Check>
162
+
163
+ <Warning>
164
+ **Field must be focused**
165
+
166
+ Typing will only work if an input field is currently focused. If no field is focused, the text may be lost or trigger unexpected keyboard shortcuts.
167
+ </Warning>
168
+
169
+ ## Use Cases
170
+
171
+ <AccordionGroup>
172
+ <Accordion title="Login Forms">
173
+ ```javascript
174
+ await testdriver.focusApplication('Google Chrome');
175
+
176
+ const usernameField = await testdriver.find('username input');
177
+ await usernameField.click();
178
+ await testdriver.type('testuser@example.com');
179
+
180
+ await testdriver.pressKeys(['tab']);
181
+ await testdriver.type('MyP@ssword123', { secret: true });
182
+
183
+ await testdriver.pressKeys(['enter']);
184
+ ```
185
+ </Accordion>
186
+
187
+ <Accordion title="Search Fields">
188
+ ```javascript
189
+ const searchBox = await testdriver.find('search input');
190
+ await searchBox.click();
191
+ await testdriver.type('laptop computers');
192
+ await testdriver.pressKeys(['enter']);
193
+
194
+ // Wait for results
195
+ await new Promise(r => setTimeout(r, 2000));
196
+ ```
197
+ </Accordion>
198
+
199
+ <Accordion title="Multi-Field Forms">
200
+ ```javascript
201
+ // First field
202
+ const nameField = await testdriver.find('full name input');
203
+ await nameField.click();
204
+ await testdriver.type('Jane Smith');
205
+
206
+ // Navigate with Tab
207
+ await testdriver.pressKeys(['tab']);
208
+ await testdriver.type('jane.smith@example.com');
209
+
210
+ await testdriver.pressKeys(['tab']);
211
+ await testdriver.type('+1-555-0123');
212
+
213
+ await testdriver.pressKeys(['tab']);
214
+ await testdriver.type('123 Main Street');
215
+ ```
216
+ </Accordion>
217
+
218
+ <Accordion title="Text Editors">
219
+ ```javascript
220
+ const editor = await testdriver.find('text editor area');
221
+ await editor.click();
222
+
223
+ await testdriver.type('# My Document', 100);
224
+ await testdriver.pressKeys(['enter', 'enter']);
225
+ await testdriver.type('This is the first paragraph.', 50);
226
+ ```
227
+ </Accordion>
228
+
229
+ <Accordion title="Numeric Input">
230
+ ```javascript
231
+ const quantityField = await testdriver.find('quantity input');
232
+ await quantityField.click();
233
+
234
+ // Clear field
235
+ await testdriver.pressKeys(['ctrl', 'a']);
236
+
237
+ // Type number
238
+ await testdriver.type(5);
239
+ ```
240
+ </Accordion>
241
+ </AccordionGroup>
242
+
243
+ ## Typing Speed
244
+
245
+ Adjust the delay parameter based on your needs:
246
+
247
+ ```javascript
248
+ // Fast typing (100ms delay)
249
+ await testdriver.type('quick entry', 100);
250
+
251
+ // Normal typing (250ms - default)
252
+ await testdriver.type('standard speed');
253
+
254
+ // Slow typing (500ms delay) - useful for fields with live validation
255
+ await testdriver.type('slow and steady', 500);
256
+
257
+ // Very slow (1000ms delay) - for problematic fields
258
+ await testdriver.type('one by one', 1000);
259
+ ```
260
+
261
+ <Note>
262
+ Some applications with live validation or autocomplete may require slower typing speeds to avoid race conditions.
263
+ </Note>
264
+
265
+ ## Special Characters
266
+
267
+ ```javascript
268
+ // Email addresses
269
+ await testdriver.type('user@example.com');
270
+
271
+ // URLs
272
+ await testdriver.type('https://example.com/path?query=value');
273
+
274
+ // Passwords with special characters
275
+ await testdriver.type('P@ssw0rd!#$%');
276
+
277
+ // Paths
278
+ await testdriver.type('C:\\Users\\Documents\\file.txt');
279
+
280
+ // Multi-line text (use pressKeys for Enter)
281
+ await testdriver.type('Line 1');
282
+ await testdriver.pressKeys(['enter']);
283
+ await testdriver.type('Line 2');
284
+ ```
285
+
286
+ ## Complete Example
287
+
288
+ ```javascript
289
+ import { beforeAll, afterAll, describe, it, expect } from 'vitest';
290
+ import TestDriver from 'testdriverai';
291
+
292
+ describe('Form Filling with Type', () => {
293
+ let testdriver;
294
+
295
+ beforeAll(async () => {
296
+ client = new TestDriver(process.env.TD_API_KEY);
297
+ await testdriver.auth();
298
+ await testdriver.connect();
299
+ });
300
+
301
+ afterAll(async () => {
302
+ await testdriver.disconnect();
303
+ });
304
+
305
+ it('should fill out registration form', async () => {
306
+ await testdriver.focusApplication('Google Chrome');
307
+
308
+ // Email field
309
+ const emailField = await testdriver.find('email input field');
310
+ await emailField.click();
311
+ await testdriver.type('john.doe@example.com');
312
+
313
+ // Tab through form fields
314
+ await testdriver.pressKeys(['tab']);
315
+ await testdriver.type('John');
316
+
317
+ await testdriver.pressKeys(['tab']);
318
+ await testdriver.type('Doe');
319
+
320
+ await testdriver.pressKeys(['tab']);
321
+ await testdriver.type('MySecureP@ssword123');
322
+
323
+ await testdriver.pressKeys(['tab']);
324
+ await testdriver.type('MySecureP@ssword123'); // Confirm password
325
+
326
+ // Verify fields were filled
327
+ const result = await testdriver.assert('all form fields are filled');
328
+ expect(result).toBeTruthy();
329
+ });
330
+
331
+ it('should update search query', async () => {
332
+ const searchBox = await testdriver.find('search input');
333
+ await searchBox.click();
334
+
335
+ // Type initial search
336
+ await testdriver.type('laptops');
337
+ await testdriver.pressKeys(['enter']);
338
+
339
+ await new Promise(r => setTimeout(r, 2000));
340
+
341
+ // Update search
342
+ await searchBox.click();
343
+ await testdriver.pressKeys(['ctrl', 'a']); // Select all
344
+ await testdriver.type('gaming laptops');
345
+ await testdriver.pressKeys(['enter']);
346
+
347
+ // Verify new search
348
+ await testdriver.assert('search results for "gaming laptops" are shown');
349
+ });
350
+ });
351
+ ```
352
+
353
+ ## Related Methods
354
+
355
+ - [`pressKeys()`](/v7/press-keys) - Press keyboard keys and shortcuts
356
+ - [`find()`](/v7/find) - Locate input fields
357
+ - [`click()`](/v7/click) - Focus input fields
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: testdriver:variables
3
+ description: Use dynamic data and secure secrets in your tests
4
+ ---
5
+ <!-- Generated from variables.mdx. DO NOT EDIT. -->
6
+
7
+ Scale your testing with dynamic data and secure secrets management. Choose the right approach based on your testing needs.
8
+
9
+ ## Environment Variables
10
+
11
+ Environment variables are ideal for **configuration that changes between environments** (dev, staging, production) or for **secrets that shouldn't be committed to code**. Use this approach when you need to run the same tests against different servers or with different credentials.
12
+
13
+ ```javascript
14
+ import { test } from 'vitest';
15
+ import { chrome } from 'testdriverai/presets';
16
+
17
+ test('multi-environment testing', async (context) => {
18
+ const env = process.env.TEST_ENV || 'staging';
19
+ const urls = {
20
+ dev: 'https://dev.myapp.com',
21
+ staging: 'https://staging.myapp.com',
22
+ production: 'https://myapp.com'
23
+ };
24
+
25
+ const { testdriver } = await chrome(context, {
26
+ url: urls[env]
27
+ });
28
+
29
+ await testdriver.assert('app is running');
30
+ });
31
+ ```
32
+
33
+ ```bash
34
+ # Run against different environments
35
+ TEST_ENV=dev vitest run
36
+ TEST_ENV=staging vitest run
37
+ TEST_ENV=production vitest run
38
+ ```
39
+
40
+ ## Test Fixtures
41
+
42
+ Test fixtures work best when you have **structured, reusable test data** that needs to be shared across multiple tests. Use fixtures when testing different user roles, product catalogs, or any scenario where you want to parameterize tests with a known set of data.
43
+
44
+ ```javascript test/fixtures/users.js
45
+ export const testUsers = [
46
+ { email: 'admin@test.com', role: 'admin' },
47
+ { email: 'user@test.com', role: 'user' },
48
+ { email: 'guest@test.com', role: 'guest' }
49
+ ];
50
+
51
+ export const products = [
52
+ { name: 'Laptop', price: 999 },
53
+ { name: 'Mouse', price: 29 },
54
+ { name: 'Keyboard', price: 89 }
55
+ ];
56
+ ```
57
+
58
+ ```javascript test/permissions.test.js
59
+ import { test } from 'vitest';
60
+ import { chrome } from 'testdriverai/presets';
61
+ import { testUsers } from './fixtures/users.js';
62
+
63
+ test.each(testUsers)('$role can access dashboard', async ({ email, role }, context) => {
64
+ const { testdriver } = await chrome(context, { url });
65
+
66
+ await testdriver.find('email input').type(email);
67
+ await testdriver.find('password input').type('password123');
68
+ await testdriver.find('login button').click();
69
+
70
+ if (role === 'admin') {
71
+ await testdriver.assert('admin panel is visible');
72
+ } else {
73
+ await testdriver.assert('user dashboard is visible');
74
+ }
75
+ });
76
+ ```
77
+
78
+ ## Dynamic Data Generation
79
+
80
+ Dynamic data generation is perfect for **creating unique test data on each run**, avoiding conflicts with existing records, and **testing edge cases with realistic data**. Use libraries like Faker when you need fresh emails, names, or other data that won't collide with previous test runs.
81
+
82
+ ```javascript
83
+ import { test } from 'vitest';
84
+ import { chrome } from 'testdriverai/presets';
85
+ import { faker } from '@faker-js/faker';
86
+
87
+ test('user registration with dynamic data', async (context) => {
88
+ const { testdriver } = await chrome(context, { url });
89
+
90
+ // Generate unique test data for each run
91
+ const userData = {
92
+ firstName: faker.person.firstName(),
93
+ lastName: faker.person.lastName(),
94
+ email: faker.internet.email(),
95
+ password: faker.internet.password({ length: 12 })
96
+ };
97
+
98
+ await testdriver.find('first name input').type(userData.firstName);
99
+ await testdriver.find('last name input').type(userData.lastName);
100
+ await testdriver.find('email input').type(userData.email);
101
+ await testdriver.find('password input').type(userData.password);
102
+ await testdriver.find('register button').click();
103
+
104
+ await testdriver.assert('registration successful');
105
+ console.log('Registered user:', userData.email);
106
+ });
107
+ ```
108
+
109
+ ```bash
110
+ npm install --save-dev @faker-js/faker
111
+ ```
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: testdriver:waiting-for-elements
3
+ description: Handle async operations and prevent flaky tests
4
+ ---
5
+ <!-- Generated from waiting-for-elements.mdx. DO NOT EDIT. -->
6
+
7
+ ## Waiting for Elements
8
+
9
+ Use the `timeout` option with `find()` to wait for elements that appear after async operations:
10
+
11
+ ```javascript
12
+ // Wait up to 30 seconds for element to appear (polls every 5 seconds)
13
+ const element = await testdriver.find('Loading complete indicator', { timeout: 30000 });
14
+ await element.click();
15
+
16
+ // Useful after actions that trigger loading states
17
+ await testdriver.find('submit button').click();
18
+ await testdriver.find('success message', { timeout: 15000 });
19
+
20
+ // Short timeout for quick checks
21
+ const toast = await testdriver.find('notification toast', { timeout: 5000 });
22
+ ```
23
+
24
+ ## Flake Prevention
25
+
26
+ TestDriver automatically waits for the screen and network to stabilize after each action using **redraw detection**. This prevents flaky tests caused by animations, loading states, or dynamic content updates.
27
+
28
+ <Note>
29
+ Redraw detection adds a small delay after each action but significantly reduces test flakiness.
30
+ </Note>
31
+
32
+ For example, when clicking a submit button that navigates to a new page:
33
+
34
+ ```javascript
35
+ // Click submit - TestDriver automatically waits for the new page to load
36
+ await testdriver.find('submit button').click();
37
+
38
+ // By the time this runs, the page has fully loaded and stabilized
39
+ await testdriver.assert('dashboard is displayed');
40
+ await testdriver.find('welcome message');
41
+ ```
42
+
43
+ Without redraw detection, you'd need manual waits or retries to handle the page transition. TestDriver handles this automatically by detecting when the screen stops changing and network requests complete.
44
+
45
+ You can disable redraw detection or customize its behavior:
46
+
47
+ ```javascript
48
+ // Disable redraw detection for faster tests (less reliable)
49
+ const testdriver = TestDriver(context, {
50
+ redraw: false
51
+ });
52
+ ```
53
+
54
+ Here is an example of customizing redraw detection:
55
+
56
+ ```javascript
57
+ // Fine-tune redraw detection
58
+ const testdriver = TestDriver(context, {
59
+ redraw: {
60
+ enabled: true,
61
+ diffThreshold: 0.1, // Pixel difference threshold (0-1)
62
+ screenRedraw: true, // Monitor screen changes
63
+ networkMonitor: true, // Wait for network idle
64
+ }
65
+ });
66
+ ```
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: testdriver:what-is-testdriver
3
+ description: Reliably test your most difficult user flows
4
+ ---
5
+ <!-- Generated from what-is-testdriver.mdx. DO NOT EDIT. -->
6
+
7
+ ## The problem with modern testing tools
8
+
9
+ Modern testing tools like Playwright are designed to test a single web application, running in a single browser tab using selectors.
10
+
11
+ However, selectors are often either unreliable or unavailable in complex scenarios, leading to brittle and flaky tests:
12
+
13
+ | Challenge | Problem | Examples |
14
+ |-----------|---------|----------|
15
+ | **Fast moving teams** | Frequently change UI structure, breaking CSS/XPath selectors | Agile teams, startups, vibe-coders |
16
+ | **Dynamic content** | Cannot be targeted with selectors | AI chatbots, PDFs, images, videos |
17
+ | **Software you don't own** | May lack proper accessibility attributes | Other websites, extensions, third-party applications |
18
+ | **Multi-application workflows** | Cannot be tested with web-only tools | Desktop apps, browser extensions, IDEs |
19
+ | **Visual states** | Impossible to verify with code-based selectors | Charts, graphs, videos, images, spelling errors, UI layout |
20
+
21
+ ## The TestDriver Solution
22
+
23
+ TestDriver is a complete testing platform built specifically for handling these scenarios. It consists of a Javascript SDK, hosted infrastructure, and debugging tools that make it easy to write, run, and maintain tests for your most difficult user flows.
24
+
25
+ ### Javascript SDK
26
+
27
+ Here is an example of a TestDriver test that installs a production Chrome extension from the Chrome Web Store and verifies that it appears in the extensions menu:
28
+
29
+ ```javascript Installing Loom from the Chrome Web Store
30
+ import { describe, expect, it } from "vitest";
31
+ import { TestDriver } from "testdriverai/vitest/hooks";
32
+
33
+ describe("Chrome Extension Test", () => {
34
+ const testdriver = TestDriver(context);
35
+
36
+ // Launch Chrome with Loom loaded by its Chrome Web Store ID
37
+ await testdriver.provision.chromeExtension({
38
+ extensionId: 'liecbddmkiiihnedobmlmillhodjkdmb'
39
+ });
40
+
41
+ // Click on the extensions button (puzzle piece icon) in Chrome toolbar
42
+ const extensionsButton = await testdriver.find("The puzzle-shaped icon in the Chrome toolbar.");
43
+ await extensionsButton.click();
44
+
45
+ // Look for Loom in the extensions menu
46
+ const loomExtension = await testdriver.find("Loom extension in the extensions dropdown");
47
+ expect(loomExtension.found()).toBeTruthy();
48
+ });
49
+ ```
50
+
51
+
52
+ <Tip>[vitest](https://vitest.dev/) is the preferred test runner for TestDriver.</Tip>
53
+
54
+ ,
@@ -30,8 +30,13 @@ jobs:
30
30
  run: npm install -g @sentry/cli
31
31
 
32
32
  - name: Report to Sentry Cron
33
+ continue-on-error: true
33
34
  run: |
34
- sentry-cli monitors run testdriver-windows-acceptance -- echo "Windows tests completed"
35
+ if [ "${{ needs.test-windows.result }}" == "success" ]; then
36
+ sentry-cli monitors run testdriver-windows-acceptance -- echo "Windows tests passed"
37
+ else
38
+ sentry-cli monitors run testdriver-windows-acceptance -- bash -c "echo 'Windows tests failed' && exit 1"
39
+ fi
35
40
  env:
36
41
  SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
37
42
 
@@ -37,25 +37,6 @@ jobs:
37
37
  TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
38
38
  TD_OS: linux
39
39
 
40
- - name: Extract example URLs
41
- if: success()
42
- run: node docs/_scripts/extract-example-urls.js --file=test-output.log
43
-
44
- - name: Generate example docs
45
- if: success()
46
- run: node docs/_scripts/generate-examples.js --skip-ai
47
- env:
48
- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
49
-
50
- - name: Commit updated docs
51
- if: success()
52
- run: |
53
- git config --local user.email "github-actions[bot]@users.noreply.github.com"
54
- git config --local user.name "github-actions[bot]"
55
- git add docs/
56
- git diff --staged --quiet || git commit -m "docs: update example documentation [skip ci]"
57
- git push || echo "No changes to push"
58
-
59
40
  - name: Upload test results to Sentry Prevent
60
41
  if: ${{ !cancelled() }}
61
42
  uses: getsentry/prevent-action@v0
@@ -111,23 +92,6 @@ jobs:
111
92
  with:
112
93
  name: test-output-windows
113
94
 
114
- - name: Extract example URLs from Windows tests
115
- if: needs.test-windows.result == 'success'
116
- run: node docs/_scripts/extract-example-urls.js --file=test-output.log
117
-
118
- - name: Generate example docs
119
- if: needs.test-windows.result == 'success'
120
- run: node docs/_scripts/generate-examples.js --skip-ai
121
-
122
- - name: Commit updated docs
123
- if: needs.test-windows.result == 'success'
124
- run: |
125
- git config --local user.email "github-actions[bot]@users.noreply.github.com"
126
- git config --local user.name "github-actions[bot]"
127
- git add docs/
128
- git diff --staged --quiet || git commit -m "docs: update example documentation from Windows tests [skip ci]"
129
- git push || echo "No changes to push"
130
-
131
95
  - name: Upload test results to Sentry Prevent
132
96
  if: ${{ !cancelled() }}
133
97
  uses: getsentry/prevent-action@v0