Skip to content

Commit b049c2e

Browse files
committed
docs updates
1 parent 7a5bc27 commit b049c2e

File tree

7 files changed

+226
-230
lines changed

7 files changed

+226
-230
lines changed

docs/docs.json

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -232,44 +232,37 @@
232232
"/v7/presets/chrome",
233233
"/v7/presets/chrome-extension",
234234
"/v7/presets/vscode",
235-
"/v7/presets/electron",
236-
"/v7/presets/webapp"
235+
"/v7/presets/electron"
236+
]
237+
},
238+
{
239+
"group": "Actions",
240+
"icon": "bolt",
241+
"pages": [
242+
"/v7/api/act",
243+
"/v7/api/assert",
244+
"/v7/api/assertions",
245+
"/v7/api/click",
246+
"/v7/api/doubleClick",
247+
"/v7/api/exec",
248+
"/v7/api/find",
249+
"/v7/api/focusApplication",
250+
"/v7/api/hover",
251+
"/v7/api/mouseDown",
252+
"/v7/api/mouseUp",
253+
"/v7/api/pressKeys",
254+
"/v7/api/rightClick",
255+
"/v7/api/type",
256+
"/v7/api/scroll"
237257
]
238258
},
239259
{
240260
"group": "API Reference",
241261
"icon": "book",
242262
"pages": [
243263
"/v7/api/client",
264+
"/v7/api/elements",
244265
"/v7/api/sandbox",
245-
{
246-
"group": "Interactions",
247-
"icon": "bolt",
248-
"pages": [
249-
"/v7/api/find",
250-
"/v7/api/elements",
251-
"/v7/api/click",
252-
"/v7/api/doubleClick",
253-
"/v7/api/rightClick",
254-
"/v7/api/hover",
255-
"/v7/api/mouseDown",
256-
"/v7/api/mouseUp",
257-
"/v7/api/type",
258-
"/v7/api/pressKeys",
259-
"/v7/api/scroll",
260-
"/v7/api/focusApplication"
261-
]
262-
},
263-
{
264-
"group": "AI & Assertions",
265-
"icon": "wand-magic-sparkles",
266-
"pages": [
267-
"/v7/api/act",
268-
"/v7/api/assert",
269-
"/v7/api/assertions"
270-
]
271-
},
272-
"/v7/api/exec",
273266
"/v7/api/dashcam"
274267
]
275268
}

docs/v7/getting-started/quickstart.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ TestDriver v7 lets you write AI-powered tests in JavaScript/TypeScript with full
4444
<Tab title="Fast">
4545
```javascript test.test.js
4646
import { test } from 'vitest';
47-
import { chrome } from 'testdriverai/presets';
47+
import { TestDriver } from 'testdriverai/vitest/hooks';
4848

4949
test('my first test', async (context) => {
50-
const { testdriver } = await chrome(context, {
51-
url: 'https://example.com',
50+
const testdriver = TestDriver(context, {
51+
headless: true,
5252
apiKey: 'tdai-1234567890abcdef' // Your API key from console.testdriver.ai
5353
});
5454

55+
await testdriver.provision.chrome({ url: 'https://example.com' });
56+
5557
await testdriver.find('More information link').click();
5658
await testdriver.assert('IANA page is visible');
5759
});
@@ -73,13 +75,13 @@ TestDriver v7 lets you write AI-powered tests in JavaScript/TypeScript with full
7375

7476
```javascript test.test.js
7577
import { test } from 'vitest';
76-
import { chrome } from 'testdriverai/presets';
78+
import { TestDriver } from 'testdriverai/vitest/hooks';
7779

7880
test('my first test', async (context) => {
79-
const { testdriver } = await chrome(context, {
80-
url: 'https://example.com'
81-
// apiKey automatically read from process.env.TD_API_KEY
82-
});
81+
const testdriver = TestDriver(context, { headless: true });
82+
// apiKey automatically read from process.env.TD_API_KEY
83+
84+
await testdriver.provision.chrome({ url: 'https://example.com' });
8385

8486
await testdriver.find('More information link').click();
8587
await testdriver.assert('IANA page is visible');
@@ -111,7 +113,7 @@ TestDriver v7 lets you write AI-powered tests in JavaScript/TypeScript with full
111113

112114
## What Just Happened?
113115

114-
The `chrome()` preset automatically:
116+
The TestDriver hook with `provision.chrome()` automatically:
115117
1. ✅ Connected to a TestDriver sandbox
116118
2. ✅ Launched Chrome browser
117119
3. ✅ Navigated to your URL

docs/v7/getting-started/running-and-debugging.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ Every test automatically records a video replay:
101101
<Step title="Get Replay URL">
102102
```javascript
103103
test('my test', async (context) => {
104-
const { testdriver, dashcam } = await chrome(context, { url });
104+
const testdriver = TestDriver(context, { headless: true });
105+
await testdriver.provision.chrome({ url });
105106

106107
// Your test code
107108

108-
console.log('Replay:', dashcam.url);
109+
console.log('Replay:', testdriver.dashcam.url);
109110
});
110111
```
111112

docs/v7/getting-started/writing-tests.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ Every TestDriver test follows this simple pattern:
1212

1313
```javascript
1414
import { test } from 'vitest';
15-
import { chrome } from 'testdriverai/presets';
15+
import { TestDriver } from 'testdriverai/vitest/hooks';
1616

1717
test('descriptive test name', async (context) => {
1818
// 1. Setup: Launch and navigate
19-
const { testdriver } = await chrome(context, {
20-
url: 'https://myapp.com'
21-
});
19+
const testdriver = TestDriver(context, { headless: true });
20+
await testdriver.provision.chrome({ url: 'https://myapp.com' });
2221

2322
// 2. Act: Interact with your application
2423
await testdriver.find('email input').type('[email protected]');
@@ -30,7 +29,7 @@ test('descriptive test name', async (context) => {
3029
```
3130

3231
<Tip>
33-
The preset handles all setup and cleanup automatically - no need for manual browser management!
32+
The TestDriver hook handles all setup and cleanup automatically - no need for manual browser management!
3433
</Tip>
3534

3635
## Finding Elements

docs/v7/presets/chrome.mdx

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The `chrome()` preset automatically sets up a Chrome browser with TestDriver and
1616
import { TestDriver } from 'testdriverai/vitest/hooks';
1717

1818
test('my test', async (context) => {
19-
const testdriver = TestDriver(context);
19+
const testdriver = TestDriver(context, { headless: true });
2020
await testdriver.provision.chrome({ url: 'https://example.com' });
2121
// ...
2222
});
@@ -29,12 +29,12 @@ The `chrome()` preset automatically sets up a Chrome browser with TestDriver and
2929

3030
```javascript
3131
import { test } from 'vitest';
32-
import { chrome } from 'testdriverai/presets';
32+
import { TestDriver } from 'testdriverai/vitest/hooks';
3333

3434
test('login test', async (context) => {
35-
const { testdriver } = await chrome(context, {
36-
url: 'https://myapp.com/login'
37-
});
35+
const testdriver = TestDriver(context, { headless: true });
36+
37+
await testdriver.provision.chrome({ url: 'https://myapp.com/login' });
3838

3939
await testdriver.find('email input').type('[email protected]');
4040
await testdriver.find('password input').type('password123');
@@ -98,12 +98,12 @@ chrome(context, options): Promise<ChromeResult>
9898

9999
```javascript
100100
import { test } from 'vitest';
101-
import { chrome } from 'testdriverai/presets';
101+
import { TestDriver } from 'testdriverai/vitest/hooks';
102102

103103
test('search functionality', async (context) => {
104-
const { testdriver } = await chrome(context, {
105-
url: 'https://example.com'
106-
});
104+
const testdriver = TestDriver(context, { headless: true });
105+
106+
await testdriver.provision.chrome({ url: 'https://example.com' });
107107

108108
await testdriver.find('search input').type('TestDriver');
109109
await testdriver.find('search button').click();
@@ -115,13 +115,12 @@ test('search functionality', async (context) => {
115115

116116
```javascript
117117
import { test, expect } from 'vitest';
118-
import { chrome } from 'testdriverai/presets';
118+
import { TestDriver } from 'testdriverai/vitest/hooks';
119119

120120
test('checkout flow', async (context) => {
121-
const { testdriver, dashcam } = await chrome(context, {
122-
url: 'https://shop.example.com',
123-
maximized: true
124-
});
121+
const testdriver = TestDriver(context, { headless: true });
122+
123+
await testdriver.provision.chrome({ url: 'https://shop.example.com' });
125124

126125
// Add items to cart
127126
await testdriver.find('Add to Cart button').click();
@@ -149,22 +148,20 @@ test('checkout flow', async (context) => {
149148

150149
```javascript
151150
import { test } from 'vitest';
152-
import { chrome } from 'testdriverai/presets';
151+
import { TestDriver } from 'testdriverai/vitest/hooks';
153152

154153
test('windows chrome test', async (context) => {
155-
const { testdriver } = await chrome(context, {
156-
url: 'https://myapp.com',
157-
os: 'windows'
158-
});
154+
const testdriver = TestDriver(context, { headless: true, os: 'windows' });
155+
156+
await testdriver.provision.chrome({ url: 'https://myapp.com' });
159157

160158
await testdriver.find('Start').click();
161159
});
162160

163161
test('mac chrome test', async (context) => {
164-
const { testdriver } = await chrome(context, {
165-
url: 'https://myapp.com',
166-
os: 'mac'
167-
});
162+
const testdriver = TestDriver(context, { headless: true, os: 'mac' });
163+
164+
await testdriver.provision.chrome({ url: 'https://myapp.com' });
168165

169166
await testdriver.find('Start').click();
170167
});
@@ -174,13 +171,12 @@ test('mac chrome test', async (context) => {
174171

175172
```javascript
176173
import { test } from 'vitest';
177-
import { chrome } from 'testdriverai/presets';
174+
import { TestDriver } from 'testdriverai/vitest/hooks';
178175

179176
test('quick test without recording', async (context) => {
180-
const { testdriver } = await chrome(context, {
181-
url: 'https://example.com',
182-
dashcam: false // Disable Dashcam for faster execution
183-
});
177+
const testdriver = TestDriver(context, { headless: true, dashcam: false });
178+
179+
await testdriver.provision.chrome({ url: 'https://example.com' });
184180

185181
await testdriver.find('button').click();
186182
});
@@ -190,13 +186,14 @@ test('quick test without recording', async (context) => {
190186

191187
```javascript
192188
import { test } from 'vitest';
193-
import { chrome } from 'testdriverai/presets';
189+
import { TestDriver } from 'testdriverai/vitest/hooks';
194190

195191
test('chrome extension', async (context) => {
196-
const { testdriver } = await chrome(context, {
192+
const testdriver = TestDriver(context, { headless: true });
193+
194+
await testdriver.provision.chrome({
197195
url: 'chrome://extensions',
198-
guest: false, // Need profile for extensions
199-
maximized: true
196+
guest: false // Need profile for extensions
200197
});
201198

202199
await testdriver.find('Developer mode toggle').click();
@@ -226,9 +223,9 @@ At test end:
226223

227224
```javascript
228225
test('user registration', async (context) => {
229-
const { testdriver } = await chrome(context, {
230-
url: 'https://myapp.com/register'
231-
});
226+
const testdriver = TestDriver(context, { headless: true });
227+
228+
await testdriver.provision.chrome({ url: 'https://myapp.com/register' });
232229

233230
await testdriver.find('email field').type('[email protected]');
234231
await testdriver.find('password field').type('SecurePass123!');
@@ -244,9 +241,9 @@ test('user registration', async (context) => {
244241

245242
```javascript
246243
test('multi-page navigation', async (context) => {
247-
const { testdriver } = await chrome(context, {
248-
url: 'https://myapp.com'
249-
});
244+
const testdriver = TestDriver(context, { headless: true });
245+
246+
await testdriver.provision.chrome({ url: 'https://myapp.com' });
250247

251248
// Navigate through pages
252249
await testdriver.find('About link').click();
@@ -265,9 +262,9 @@ test('multi-page navigation', async (context) => {
265262
```javascript
266263
test('handles errors gracefully', async (context) => {
267264
try {
268-
const { testdriver } = await chrome(context, {
269-
url: 'https://myapp.com'
270-
});
265+
const testdriver = TestDriver(context, { headless: true });
266+
267+
await testdriver.provision.chrome({ url: 'https://myapp.com' });
271268

272269
await testdriver.find('non-existent element').click();
273270
} catch (error) {

0 commit comments

Comments
 (0)