Skip to content

Commit fac3632

Browse files
authored
chore: add expectAria to perform (#38640)
1 parent 1a51420 commit fac3632

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1911
-702
lines changed

docs/src/api/class-page.md

Lines changed: 4 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,10 @@ current working directory.
720720

721721
Raw CSS content to be injected into frame.
722722

723+
## property: Page.agent
724+
* since: v1.58
725+
- type: <[PageAgent]>
726+
723727
## async method: Page.bringToFront
724728
* since: v1.8
725729

@@ -2035,49 +2039,6 @@ Name of the function on the window object
20352039

20362040
Callback function which will be called in Playwright's context.
20372041

2038-
## async method: Page.extract
2039-
* since: v1.58
2040-
- returns: <[Object]>
2041-
- `result` <[any]>
2042-
- `usage` <[Object]>
2043-
- `turns` <[int]>
2044-
- `inputTokens` <[int]>
2045-
- `outputTokens` <[int]>
2046-
2047-
Extract information from the page using the agentic loop, return it in a given Zod format.
2048-
2049-
**Usage**
2050-
2051-
```js
2052-
await page.extract('List of items in the cart', z.object({
2053-
title: z.string().describe('Item title to extract'),
2054-
price: z.string().describe('Item price to extract'),
2055-
}).array());
2056-
```
2057-
2058-
### param: Page.extract.query
2059-
* since: v1.58
2060-
- `query` <[string]>
2061-
2062-
Task to perform using agentic loop.
2063-
2064-
### param: Page.extract.schema
2065-
* since: v1.58
2066-
- `schema` <[z.ZodSchema]>
2067-
2068-
### option: Page.extract.maxTokens
2069-
* since: v1.58
2070-
- `maxTokens` <[int]>
2071-
2072-
Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value.
2073-
Defaults to context-wide value specified in `agent` property.
2074-
2075-
### option: Page.extract.maxTurns
2076-
* since: v1.58
2077-
- `maxTurns` <[int]>
2078-
2079-
Maximum number of agentic turns during this call, defaults to context-wide value specified in `agent` property.
2080-
20812042
## async method: Page.fill
20822043
* since: v1.8
20832044
* discouraged: Use locator-based [`method: Locator.fill`] instead. Read more about [locators](../locators.md).
@@ -3051,48 +3012,6 @@ Whether or not to generate tagged (accessible) PDF. Defaults to `false`.
30513012

30523013
Whether or not to embed the document outline into the PDF. Defaults to `false`.
30533014

3054-
## async method: Page.perform
3055-
* since: v1.58
3056-
- returns: <[Object]>
3057-
- `usage` <[Object]>
3058-
- `turns` <[int]>
3059-
- `inputTokens` <[int]>
3060-
- `outputTokens` <[int]>
3061-
3062-
Perform action using agentic loop.
3063-
3064-
**Usage**
3065-
3066-
```js
3067-
await page.perform('Click submit button');
3068-
```
3069-
3070-
### param: Page.perform.task
3071-
* since: v1.58
3072-
- `task` <[string]>
3073-
3074-
Task to perform using agentic loop.
3075-
3076-
### option: Page.perform.key
3077-
* since: v1.58
3078-
- `key` <[string]>
3079-
3080-
All the agentic actions are converted to the Playwright calls and are cached.
3081-
By default, they are cached globally with the `task` as a key. This option allows controlling the cache key explicitly.
3082-
3083-
### option: Page.perform.maxTokens
3084-
* since: v1.58
3085-
- `maxTokens` <[int]>
3086-
3087-
Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value.
3088-
Defaults to context-wide value specified in `agent` property.
3089-
3090-
### option: Page.perform.maxTurns
3091-
* since: v1.58
3092-
- `maxTurns` <[int]>
3093-
3094-
Maximum number of agentic turns during this call, defaults to context-wide value specified in `agent` property.
3095-
30963015

30973016
## async method: Page.press
30983017
* since: v1.8

docs/src/api/class-pageagent.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# class: PageAgent
2+
* since: v1.58
3+
4+
5+
## async method: PageAgent.expect
6+
* since: v1.58
7+
8+
Expect certain condition to be met.
9+
10+
**Usage**
11+
12+
```js
13+
await page.agent.expect('"0 items" to be reported');
14+
```
15+
16+
### param: PageAgent.expect.expectation
17+
* since: v1.58
18+
- `expectation` <[string]>
19+
20+
Expectation to assert.
21+
22+
### option: PageAgent.expect.-inline- = %%-page-agent-call-options-v1.58-%%
23+
* since: v1.58
24+
25+
## async method: PageAgent.extract
26+
* since: v1.58
27+
- returns: <[Object]>
28+
- `result` <[any]>
29+
- `usage` <[Object]>
30+
- `turns` <[int]>
31+
- `inputTokens` <[int]>
32+
- `outputTokens` <[int]>
33+
34+
Extract information from the page using the agentic loop, return it in a given Zod format.
35+
36+
**Usage**
37+
38+
```js
39+
await page.agent.extract('List of items in the cart', z.object({
40+
title: z.string().describe('Item title to extract'),
41+
price: z.string().describe('Item price to extract'),
42+
}).array());
43+
```
44+
45+
### param: PageAgent.extract.query
46+
* since: v1.58
47+
- `query` <[string]>
48+
49+
Task to perform using agentic loop.
50+
51+
### param: PageAgent.extract.schema
52+
* since: v1.58
53+
- `schema` <[z.ZodSchema]>
54+
55+
### option: PageAgent.extract.-inline- = %%-page-agent-call-options-v1.58-%%
56+
* since: v1.58
57+
58+
59+
## async method: PageAgent.perform
60+
* since: v1.58
61+
- returns: <[Object]>
62+
- `usage` <[Object]>
63+
- `turns` <[int]>
64+
- `inputTokens` <[int]>
65+
- `outputTokens` <[int]>
66+
67+
Perform action using agentic loop.
68+
69+
**Usage**
70+
71+
```js
72+
await page.agent.perform('Click submit button');
73+
```
74+
75+
### param: PageAgent.perform.task
76+
* since: v1.58
77+
- `task` <[string]>
78+
79+
Task to perform using agentic loop.
80+
81+
### option: PageAgent.perform.-inline- = %%-page-agent-call-options-v1.58-%%
82+
* since: v1.58

docs/src/api/params.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,32 @@ Emulates consistent window screen size available inside web page via `window.scr
380380
- `maxTurns` ?<[int]> Maximum number of agentic turns to take per call. Defaults to 10.
381381
- `maxTokens` ?<[int]> Maximum number of tokens to consume per call. The agentic loop will stop after input + output tokens exceed this value. Defaults on unlimited.
382382

383-
Agent settings for [`method: Page.perform`] and [`method: Page.extract`].
383+
Agent settings for [`property: Page.agent`].
384+
385+
## page-agent-key
386+
* since: v1.58
387+
- `key` <[string]>
388+
389+
All the agentic actions are converted to the Playwright calls and are cached.
390+
By default, they are cached globally with the `task` as a key. This option allows controlling the cache key explicitly.
391+
392+
## page-agent-max-tokens
393+
* since: v1.58
394+
- `maxTokens` <[int]>
395+
396+
Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value.
397+
Defaults to context-wide value specified in `agent` property.
398+
399+
## page-agent-max-turns
400+
* since: v1.58
401+
- `maxTurns` <[int]>
402+
403+
Maximum number of agentic turns during this call, defaults to context-wide value specified in `agent` property.
404+
405+
## page-agent-call-options-v1.58
406+
- %%-page-agent-key-%%
407+
- %%-page-agent-max-tokens-%%
408+
- %%-page-agent-max-turns-%%
384409

385410
## fetch-param-url
386411
- `url` <[string]>

docs/src/test-api/class-fullconfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Base directory for all relative paths used in the reporters.
108108
* since: v1.58
109109
- type: <['RunAgentsMode]<"all"|"missing"|"none">>
110110

111-
Whether to run LLM agent for [`method: Page.perform`]:
111+
Whether to run LLM agent for [`property: Page.agent`]:
112112
* "all" disregards existing cache and performs all actions via LLM
113113
* "missing" only performs actions that don't have generated cache actions
114114
* "none" does not talk to LLM at all, relies on the cached actions (default)

docs/src/test-api/class-testconfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export default defineConfig({
518518
* since: v1.58
519519
- type: ?<['RunAgentsMode]<"all"|"missing"|"none">>
520520

521-
Whether to run LLM agent for [`method: Page.perform`]:
521+
Whether to run LLM agent for [`property: Page.agent`]:
522522
* "all" disregards existing cache and performs all actions via LLM
523523
* "missing" only performs actions that don't have generated cache actions
524524
* "none" does not talk to LLM at all, relies on the cached actions (default)

examples/todomvc/tests/adding-new-todos/add-multiple-todos-2.spec.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/todomvc/tests/adding-new-todos/add-multiple-todos-2.spec.ts-cache.json

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)