playwright-core 1.58.0-alpha-2025-12-06 → 1.58.0-alpha-2025-12-07
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.
- package/lib/client/page.js +7 -0
- package/lib/protocol/validator.js +31 -1
- package/lib/server/browserContext.js +1 -1
- package/package.json +1 -1
- package/types/types.d.ts +74 -0
package/lib/client/page.js
CHANGED
|
@@ -62,6 +62,7 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
62
62
|
this._closeWasCalled = false;
|
|
63
63
|
this._harRouters = [];
|
|
64
64
|
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
65
|
+
this._instrumentation.onPage(this);
|
|
65
66
|
this._browserContext = parent;
|
|
66
67
|
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(this._platform, this._browserContext._timeoutSettings);
|
|
67
68
|
this.keyboard = new import_input.Keyboard(this);
|
|
@@ -673,6 +674,12 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
673
674
|
}
|
|
674
675
|
return result.pdf;
|
|
675
676
|
}
|
|
677
|
+
async perform(task, options = {}) {
|
|
678
|
+
throw new Error("Not implemented in playwright-core");
|
|
679
|
+
}
|
|
680
|
+
extract(query, schema, options = {}) {
|
|
681
|
+
throw new Error("Not implemented in playwright-core");
|
|
682
|
+
}
|
|
676
683
|
async _snapshotForAI(options = {}) {
|
|
677
684
|
return await this._channel.snapshotForAI({ timeout: this._timeoutSettings.timeout(options), track: options.track });
|
|
678
685
|
}
|
|
@@ -608,6 +608,12 @@ import_validatorPrimitives.scheme.BrowserTypeLaunchPersistentContextParams = (0,
|
|
|
608
608
|
serviceWorkers: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["allow", "block"])),
|
|
609
609
|
selectorEngines: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("SelectorEngine"))),
|
|
610
610
|
testIdAttributeName: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
611
|
+
agent: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
612
|
+
provider: import_validatorPrimitives.tString,
|
|
613
|
+
model: import_validatorPrimitives.tString,
|
|
614
|
+
cacheDir: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
615
|
+
cacheMode: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["ignore", "force", "auto"]))
|
|
616
|
+
})),
|
|
611
617
|
userDataDir: import_validatorPrimitives.tString,
|
|
612
618
|
slowMo: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tFloat)
|
|
613
619
|
});
|
|
@@ -700,6 +706,12 @@ import_validatorPrimitives.scheme.BrowserNewContextParams = (0, import_validator
|
|
|
700
706
|
serviceWorkers: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["allow", "block"])),
|
|
701
707
|
selectorEngines: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("SelectorEngine"))),
|
|
702
708
|
testIdAttributeName: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
709
|
+
agent: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
710
|
+
provider: import_validatorPrimitives.tString,
|
|
711
|
+
model: import_validatorPrimitives.tString,
|
|
712
|
+
cacheDir: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
713
|
+
cacheMode: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["ignore", "force", "auto"]))
|
|
714
|
+
})),
|
|
703
715
|
proxy: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
704
716
|
server: import_validatorPrimitives.tString,
|
|
705
717
|
bypass: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
@@ -771,6 +783,12 @@ import_validatorPrimitives.scheme.BrowserNewContextForReuseParams = (0, import_v
|
|
|
771
783
|
serviceWorkers: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["allow", "block"])),
|
|
772
784
|
selectorEngines: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("SelectorEngine"))),
|
|
773
785
|
testIdAttributeName: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
786
|
+
agent: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
787
|
+
provider: import_validatorPrimitives.tString,
|
|
788
|
+
model: import_validatorPrimitives.tString,
|
|
789
|
+
cacheDir: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
790
|
+
cacheMode: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["ignore", "force", "auto"]))
|
|
791
|
+
})),
|
|
774
792
|
proxy: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
775
793
|
server: import_validatorPrimitives.tString,
|
|
776
794
|
bypass: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
@@ -886,7 +904,13 @@ import_validatorPrimitives.scheme.BrowserContextInitializer = (0, import_validat
|
|
|
886
904
|
strictSelectors: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tBoolean),
|
|
887
905
|
serviceWorkers: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["allow", "block"])),
|
|
888
906
|
selectorEngines: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("SelectorEngine"))),
|
|
889
|
-
testIdAttributeName: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString)
|
|
907
|
+
testIdAttributeName: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
908
|
+
agent: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
909
|
+
provider: import_validatorPrimitives.tString,
|
|
910
|
+
model: import_validatorPrimitives.tString,
|
|
911
|
+
cacheDir: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
912
|
+
cacheMode: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["ignore", "force", "auto"]))
|
|
913
|
+
}))
|
|
890
914
|
})
|
|
891
915
|
});
|
|
892
916
|
import_validatorPrimitives.scheme.BrowserContextBindingCallEvent = (0, import_validatorPrimitives.tObject)({
|
|
@@ -2776,6 +2800,12 @@ import_validatorPrimitives.scheme.AndroidDeviceLaunchBrowserParams = (0, import_
|
|
|
2776
2800
|
serviceWorkers: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["allow", "block"])),
|
|
2777
2801
|
selectorEngines: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)((0, import_validatorPrimitives.tType)("SelectorEngine"))),
|
|
2778
2802
|
testIdAttributeName: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
2803
|
+
agent: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
2804
|
+
provider: import_validatorPrimitives.tString,
|
|
2805
|
+
model: import_validatorPrimitives.tString,
|
|
2806
|
+
cacheDir: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
2807
|
+
cacheMode: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tEnum)(["ignore", "force", "auto"]))
|
|
2808
|
+
})),
|
|
2779
2809
|
pkg: (0, import_validatorPrimitives.tOptional)(import_validatorPrimitives.tString),
|
|
2780
2810
|
args: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tArray)(import_validatorPrimitives.tString)),
|
|
2781
2811
|
proxy: (0, import_validatorPrimitives.tOptional)((0, import_validatorPrimitives.tObject)({
|
|
@@ -145,7 +145,7 @@ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { co
|
|
|
145
145
|
return true;
|
|
146
146
|
}
|
|
147
147
|
static reusableContextHash(params) {
|
|
148
|
-
const paramsCopy = { ...params };
|
|
148
|
+
const paramsCopy = { ...params, agent: void 0 };
|
|
149
149
|
if (paramsCopy.selectorEngines?.length === 0)
|
|
150
150
|
delete paramsCopy.selectorEngines;
|
|
151
151
|
for (const k of Object.keys(paramsCopy)) {
|
package/package.json
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ type ElementHandleWaitForSelectorOptionsNotHidden = ElementHandleWaitForSelector
|
|
|
27
27
|
state?: 'visible'|'attached';
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
// @ts-ignore this will be any if zod is not installed
|
|
31
|
+
type ZodTypeAny = import('zod').ZodTypeAny;
|
|
32
|
+
// @ts-ignore this will be any if zod is not installed
|
|
33
|
+
type ZodInfer<T extends ZodTypeAny> = import('zod').infer<T>;
|
|
34
|
+
|
|
30
35
|
/**
|
|
31
36
|
* Page provides methods to interact with a single tab in a [Browser](https://playwright.dev/docs/api/class-browser),
|
|
32
37
|
* or an [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One
|
|
@@ -1013,6 +1018,24 @@ export interface Page {
|
|
|
1013
1018
|
*/
|
|
1014
1019
|
behavior?: 'wait'|'ignoreErrors'|'default'
|
|
1015
1020
|
}): Promise<void>;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Extract information from the page using the agentic loop, return it in a given Zod format.
|
|
1024
|
+
*
|
|
1025
|
+
* **Usage**
|
|
1026
|
+
*
|
|
1027
|
+
* ```js
|
|
1028
|
+
* await page.extract('List of items in the cart', z.object({
|
|
1029
|
+
* title: z.string().describe('Item title to extract'),
|
|
1030
|
+
* price: z.string().describe('Item price to extract'),
|
|
1031
|
+
* }).array());
|
|
1032
|
+
* ```
|
|
1033
|
+
*
|
|
1034
|
+
* @param query Task to perform using agentic loop.
|
|
1035
|
+
* @param schema
|
|
1036
|
+
* @param options
|
|
1037
|
+
*/
|
|
1038
|
+
extract<Schema extends ZodTypeAny>(query: string, schema: Schema): Promise<ZodInfer<Schema>>;
|
|
1016
1039
|
/**
|
|
1017
1040
|
* Emitted when the page closes.
|
|
1018
1041
|
*/
|
|
@@ -3796,6 +3819,31 @@ export interface Page {
|
|
|
3796
3819
|
width?: string|number;
|
|
3797
3820
|
}): Promise<Buffer>;
|
|
3798
3821
|
|
|
3822
|
+
/**
|
|
3823
|
+
* Perform action using agentic loop.
|
|
3824
|
+
*
|
|
3825
|
+
* **Usage**
|
|
3826
|
+
*
|
|
3827
|
+
* ```js
|
|
3828
|
+
* await page.perform('Click submit button');
|
|
3829
|
+
* ```
|
|
3830
|
+
*
|
|
3831
|
+
* @param task Task to perform using agentic loop.
|
|
3832
|
+
* @param options
|
|
3833
|
+
*/
|
|
3834
|
+
perform(task: string, options?: {
|
|
3835
|
+
/**
|
|
3836
|
+
* All the agentic actions are converted to the Playwright calls and are cached. By default, they are cached globally
|
|
3837
|
+
* with the `task` as a key. This option allows controlling the cache key explicitly.
|
|
3838
|
+
*/
|
|
3839
|
+
key?: string;
|
|
3840
|
+
|
|
3841
|
+
/**
|
|
3842
|
+
* Maximum number of agentic steps to take while performing this action.
|
|
3843
|
+
*/
|
|
3844
|
+
maxTurns?: number;
|
|
3845
|
+
}): Promise<void>;
|
|
3846
|
+
|
|
3799
3847
|
/**
|
|
3800
3848
|
* **NOTE** Use locator-based [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press)
|
|
3801
3849
|
* instead. Read more about [locators](https://playwright.dev/docs/locators).
|
|
@@ -22033,6 +22081,32 @@ export interface BrowserContextOptions {
|
|
|
22033
22081
|
*/
|
|
22034
22082
|
acceptDownloads?: boolean;
|
|
22035
22083
|
|
|
22084
|
+
/**
|
|
22085
|
+
* Agent settings for [page.perform(task[, options])](https://playwright.dev/docs/api/class-page#page-perform) and
|
|
22086
|
+
* [page.extract(query, schema[, options])](https://playwright.dev/docs/api/class-page#page-extract).
|
|
22087
|
+
*/
|
|
22088
|
+
agent?: {
|
|
22089
|
+
/**
|
|
22090
|
+
* LLM provider to use
|
|
22091
|
+
*/
|
|
22092
|
+
provider: string;
|
|
22093
|
+
|
|
22094
|
+
/**
|
|
22095
|
+
* Model identifier within provider
|
|
22096
|
+
*/
|
|
22097
|
+
model: string;
|
|
22098
|
+
|
|
22099
|
+
/**
|
|
22100
|
+
* Cache folder to use/generate code for performed actions into. Cache is not used if not specified (default).
|
|
22101
|
+
*/
|
|
22102
|
+
cacheDir?: string;
|
|
22103
|
+
|
|
22104
|
+
/**
|
|
22105
|
+
* Cache control, defauls to 'auto'
|
|
22106
|
+
*/
|
|
22107
|
+
cacheMode?: 'force'|'ignore'|'auto';
|
|
22108
|
+
};
|
|
22109
|
+
|
|
22036
22110
|
/**
|
|
22037
22111
|
* When using [page.goto(url[, options])](https://playwright.dev/docs/api/class-page#page-goto),
|
|
22038
22112
|
* [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route),
|