testdriverai 6.0.30-canary.ff65ed2.0 → 6.0.30

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.
@@ -1,8 +1,8 @@
1
1
  ---
2
- title: Get Started with TestDriver & Playwright
3
- sidebarTitle: Playwright
4
- tag: NEW
5
- description: In this guide, you'll setup your TestDriver account, create a new Playwright project, and leverage TestDriver's AI to convert tests to natural language.
2
+ title: "Get Started with TestDriver & Playwright"
3
+ sidebarTitle: "Playwright"
4
+ tag: "NEW"
5
+ description: "In this guide, you'll setup your TestDriver account, create a new Playwright project, and leverage TestDriver's AI to convert tests to natural language."
6
6
  icon: "masks-theater"
7
7
  ---
8
8
 
@@ -15,9 +15,9 @@ icon: "masks-theater"
15
15
  - [Perform actions](#performing-actions-with-testdriver-act) with a prompt
16
16
  - Test with an [automated agent](#agentic-tests-with-test-agent)
17
17
 
18
- We'll be incrementally converting Playwright's example test from imperactive code:
18
+ We'll be incrementally converting Playwright's example test from the sample code:
19
19
 
20
- ```typescript icon="square-js" title="tests/example.spec.ts"
20
+ ```typescript tests/example.spec.ts icon=square-js
21
21
  // Before
22
22
  test("get started link", async ({ page, testdriver }) => {
23
23
  await page.goto("https://playwright.dev/");
@@ -26,9 +26,9 @@ test("get started link", async ({ page, testdriver }) => {
26
26
  });
27
27
  ```
28
28
 
29
- To using natural language:
29
+ To using natural language with TestDriver:
30
30
 
31
- ```typescript icon="square-js" title="tests/example.spec.ts"
31
+ ```typescript tests/example.spec.ts icon=square-js
32
32
  // After
33
33
  test.describe("get started link", () => {
34
34
  test.beforeEach(async ({ page }) => page.goto("https://playwright.dev/"));
@@ -43,21 +43,15 @@ test.describe("get started link", () => {
43
43
 
44
44
  <Steps>
45
45
  <Step title="Create a TestDriver Account">
46
- You will need a [TestDriver Pro](https://app.testdriver.ai/team) account ($20/month) to get an API key.
47
-
48
- <Card
49
- title="Sign Up for TestDriver"
50
- icon="user-plus"
51
- href="https://app.testdriver.ai/team"
52
- arrow
53
- horizontal
54
- />
46
+ You will need a [TestDriver Pro](https://app.testdriver.ai/team) account (\$20/month) to get an API key.
55
47
 
48
+ <Card title="Sign Up for TestDriver" icon="user-plus" horizontal href="https://app.testdriver.ai/team">
49
+
50
+ </Card>
56
51
  </Step>
57
52
  <Step title="Set up your environment">
58
-
59
53
  Copy your API key from [the TestDriver dashboard](https://app.testdriver.ai/team), and set it as an environment variable.
60
-
54
+
61
55
  <Tabs>
62
56
  <Tab title="macOS / Linux">
63
57
  ```bash Export an environment variable on macOS or Linux systems
@@ -65,9 +59,9 @@ test.describe("get started link", () => {
65
59
  ```
66
60
  </Tab>
67
61
  <Tab title="Windows">
68
- ```powershell Export an environment variable in PowerShell
69
- setx TD_API_KEY "your_api_key_here"
70
- ```
62
+ ```powershell Export an environment variable in PowerShell
63
+ setx TD_API_KEY "your_api_key_here"
64
+ ```
71
65
  </Tab>
72
66
  </Tabs>
73
67
  </Step>
@@ -77,13 +71,11 @@ test.describe("get started link", () => {
77
71
 
78
72
  <Steps>
79
73
  <Step title="Initialize Playwright">
80
-
81
74
  <Info>
82
75
  This is a condensed version of [Playwright's Installation Instructions](https://playwright.dev/docs/intro).
83
76
 
84
77
  **If you're new to Playwright, you should follow their guide first.**
85
78
  </Info>
86
-
87
79
  In an new folder or existing run:
88
80
 
89
81
  <Tabs>
@@ -103,7 +95,6 @@ test.describe("get started link", () => {
103
95
  ```
104
96
  </Tab>
105
97
  </Tabs>
106
-
107
98
  Select the following options when prompted:
108
99
 
109
100
  ```console
@@ -136,16 +127,13 @@ test.describe("get started link", () => {
136
127
  ```
137
128
  </Tab>
138
129
  </Tabs>
139
-
140
130
  </Step>
141
131
  </Steps>
142
132
 
143
133
  ## Setup `@testdriver.ai/playwright`
144
134
 
145
135
  <Steps>
146
-
147
136
  <Step title="Install TestDriver">
148
-
149
137
  `@testdriver.ai/playwright` as a backwards-compatible wrapper around `@playwright/test`:
150
138
 
151
139
  <Tabs>
@@ -165,11 +153,8 @@ test.describe("get started link", () => {
165
153
  ```
166
154
  </Tab>
167
155
  </Tabs>
168
-
169
156
  </Step>
170
-
171
157
  <Step title="Run Playwright">
172
-
173
158
  Before we start using TestDriver in our tests, run Playwright in [UI Mode](https://playwright.dev/docs/test-ui-mode):
174
159
 
175
160
  <Tabs>
@@ -189,22 +174,18 @@ test.describe("get started link", () => {
189
174
  ```
190
175
  </Tab>
191
176
  </Tabs>
192
-
193
177
  ![Playwright UI Mode](https://playwright.dev/assets/ideal-img/ui-mode.4e54d6b.3598.png)
194
178
 
195
179
  Clicking the ▶️ button should successfully run the tests in the UI,
196
180
  just as they did before with `playwright test` in the CLI.
197
-
198
181
  </Step>
199
-
200
182
  <Step title="Import TestDriver">
201
-
202
183
  For the sake of simplicity, we'll be working with one test file for now.
203
184
 
204
185
  Open `tests/example.spec.ts` in your editor & rename the `@playwright/test`
205
186
  import to `@testdriver.ai/playwright`:
206
187
 
207
- ```typescript icon="square-js" title="tests/example.spec.ts"
188
+ ```typescript tests/example.spec.ts icon=square-js
208
189
  import { test, expect } from '@playwright/test'; // [!code --]
209
190
  import { test, expect } from '@testdriver.ai/playwright'; // [!code ++]
210
191
  ```
@@ -214,9 +195,7 @@ test.describe("get started link", () => {
214
195
  <Tip>
215
196
  Click the <Icon icon="eye" /> button to automatically re-run tests on save.
216
197
  </Tip>
217
-
218
198
  </Step>
219
-
220
199
  </Steps>
221
200
 
222
201
  ## Usage
@@ -231,7 +210,7 @@ or even having an [agent](#agentic-tests-with-test-agent) test for you!
231
210
 
232
211
  Replace `toBeVisible` with `toMatchPrompt` to assert that the element is visible on the screen:
233
212
 
234
- ```typescript icon="square-js" title="tests/example.spec.ts"
213
+ ```typescript tests/example.spec.ts icon=square-js
235
214
  // [!code --:2]
236
215
  // Expects page to have a heading with the name of Installation.
237
216
  await expect(page.getByRole("heading", { name: "Installation" })).toBeVisible();
@@ -255,7 +234,7 @@ TestDriver can replace `data-testid`s, `getByRole`, and CSS selectors with natur
255
234
 
256
235
  First, update your test to get access to the `testdriver` fixture:
257
236
 
258
- ```typescript icon="square-js" title="tests/example.spec.ts"
237
+ ```typescript tests/example.spec.ts icon=square-js
259
238
  // [!code --]
260
239
  test('get started link', async ({ page, }) => {
261
240
  // [!code ++]
@@ -264,7 +243,7 @@ test('get started link', async ({ page, testdriver }) => {
264
243
 
265
244
  Then, replace `getByRole` with `testdriver.locate`:
266
245
 
267
- ```typescript icon="square-js" title="tests/example.spec.ts"
246
+ ```typescript tests/example.spec.ts icon=square-js
268
247
  test('get started link', async ({ page, testdriver }) => {
269
248
  await page.goto('https://playwright.dev/');
270
249
 
@@ -283,22 +262,21 @@ Now, our test uses natural language to both describe & locate the element.
283
262
  <Tip>
284
263
  In the example above, you can still use Playwright to assert that the element is indeed a link for accessibility:
285
264
 
286
- ```typescript icon="square-js" title="tests/example.spec.ts"
287
- const link = await testdriver(page).locate("Get started link");
288
- // [!code ++]
289
- expect(link).toHaveRole("link");
290
- await link.click();
291
- ```
292
-
293
- This way you can write user-centric tests _and_ validate the implementation.
265
+ ```typescript tests/example.spec.ts icon=square-js
266
+ const link = await testdriver(page).locate("Get started link");
267
+ // [!code ++]
268
+ expect(link).toHaveRole("link");
269
+ await link.click();
270
+ ```
294
271
 
272
+ This way you can write user-centric tests _and_ validate the implementation.
295
273
  </Tip>
296
274
 
297
275
  ### Performing actions with `testdriver.act`
298
276
 
299
277
  We can combine `locate` and `click` from the previous example into one line with `testdriver.act`:
300
278
 
301
- ```typescript icon="square-js" title="tests/example.spec.ts"
279
+ ```typescript tests/example.spec.ts icon=square-js
302
280
  test("get started link", async ({ page, testdriver }) => {
303
281
  await page.goto("https://playwright.dev/");
304
282
 
@@ -318,7 +296,7 @@ Now the test uses the page the way a user would!
318
296
 
319
297
  TestDriver can automatically perform the entire test for you with an AI agent:
320
298
 
321
- ```typescript icon="square-js" title="tests/example.spec.ts"
299
+ ```typescript tests/example.spec.ts icon=square-js
322
300
  // [!code --:6]
323
301
  test("get started link", async ({ page, testdriver }) => {
324
302
  await page.goto("https://playwright.dev/");
@@ -340,10 +318,7 @@ Instead of writing the test implementation, we've used [`test.describe`](https:/
340
318
  but replaced the `test` itself with `test.agent`.
341
319
 
342
320
  <Tip>
343
- Use
344
- [`test.beforEach`](https://playwright.dev/docs/api/class-test#test-after-each)
345
- to prepare the page for the agent (e.g.
346
- [`page.goto`](https://playwright.dev/docs/api/class-page#page-goto), calling
321
+ Use `test.beforeEach` to prepare the page for the agent (e.g. [`page.goto`](https://playwright.dev/docs/api/class-page#page-goto), calling
347
322
  an API to create a user). Use
348
323
  [`test.afterEach`](https://playwright.dev/docs/api/class-test#test-after-each)
349
324
  to clean up after the agent (e.g. `page.close`) or perform additional logic
@@ -352,4 +327,4 @@ but replaced the `test` itself with `test.agent`.
352
327
 
353
328
  ## Conclusion
354
329
 
355
- With `@testdriver.ai/playwright`, you can use as much or as little of Playwright's _or_ TestDriver's API as you need to validate correctness. It's up to you!
330
+ With `@testdriver.ai/playwright`, you can use as much or as little of Playwright's _or_ TestDriver's API as you need to validate correctness. It's up to you!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "6.0.30-canary.ff65ed2.0",
3
+ "version": "6.0.30",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {