storybook-addon-playwright 5.3.0 → 5.4.0

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/README.md CHANGED
@@ -86,6 +86,48 @@ module.exports = function (router) {
86
86
  For a full list of available options with detailed descriptions, see the [`Config` interface in `src/typings/config.ts`](src/typings/config.ts).
87
87
  Every option is documented with a JSDoc comment explaining its purpose, parameters, and usage.
88
88
 
89
+ ### AI prompt helper for `getScreenshotTitle`
90
+
91
+ This package exports `createScreenshotTitlePrompt(data, options)` so you can build a strict LLM prompt for title generation and reuse it across projects.
92
+
93
+ The helper is designed for small models too. It asks the model to:
94
+
95
+ - parse the provided data as JSON,
96
+ - understand each field,
97
+ - generate a concise title,
98
+ - return JSON only in this shape: `{ "title": "..." }`.
99
+
100
+ Example:
101
+
102
+ ```js
103
+ const { setConfig } = require('storybook-addon-playwright/configs');
104
+ const { createScreenshotTitlePrompt } = require('storybook-addon-playwright');
105
+
106
+ async function askLlm(prompt) {
107
+ // Call your LLM provider here and return parsed JSON.
108
+ // The model response must match: { title: string }
109
+ return { title: 'Button / primary / loading' };
110
+ }
111
+
112
+ setConfig({
113
+ storybookEndpoint: 'http://localhost:6006/',
114
+ getPage: async () => {
115
+ throw new Error('Example only: implement getPage');
116
+ },
117
+ getScreenshotTitle: async (data) => {
118
+ const prompt = createScreenshotTitlePrompt(data, {
119
+ maxTitleLength: 72,
120
+ fallbackTitle: 'Should render correctly.',
121
+ includeBrowserType: true,
122
+ includeStoryId: false,
123
+ });
124
+
125
+ const result = await askLlm(prompt);
126
+ return result.title;
127
+ },
128
+ });
129
+ ```
130
+
89
131
  ## How it works
90
132
 
91
133
  The addon is an interface between Playwright and Storybook stories. It executes user-defined action sequences on the Playwright page provided in the configuration.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,45 @@
1
+ import { G as GenerateScreenshotTitleInput } from './request-B60Gnj7P.mjs';
1
2
  export { getScreenshots } from './get-screenshots.mjs';
2
3
  export { runImageDiff } from './run-image-diff.mjs';
3
4
  export { toMatchScreenshots } from './to-match-screenshots.mjs';
4
- import './get-screenshot-paths-BhXNedbs.mjs';
5
- import './request-B60Gnj7P.mjs';
6
5
  import 'playwright';
7
6
  import 'zod';
7
+ import './get-screenshot-paths-BhXNedbs.mjs';
8
8
  import './image-diff-DeB-XSUP.mjs';
9
9
  import 'jest-image-snapshot';
10
+
11
+ interface CreateScreenshotTitlePromptOptions {
12
+ /**
13
+ * Maximum number of characters allowed in the returned title.
14
+ *
15
+ * @default 80
16
+ */
17
+ maxTitleLength?: number;
18
+ /**
19
+ * Fallback title the model should use when input is too sparse.
20
+ *
21
+ * @default 'Should render correctly.'
22
+ */
23
+ fallbackTitle?: string;
24
+ /**
25
+ * Whether the generated title should include the browser type when useful.
26
+ *
27
+ * @default true
28
+ */
29
+ includeBrowserType?: boolean;
30
+ /**
31
+ * Whether the generated title can include the story id.
32
+ *
33
+ * @default false
34
+ */
35
+ includeStoryId?: boolean;
36
+ }
37
+ /**
38
+ * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
39
+ *
40
+ * The prompt enforces JSON-only output in the form:
41
+ * `{"title":"..."}`.
42
+ */
43
+ declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
44
+
45
+ export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,45 @@
1
+ import { G as GenerateScreenshotTitleInput } from './request-B60Gnj7P.js';
1
2
  export { getScreenshots } from './get-screenshots.js';
2
3
  export { runImageDiff } from './run-image-diff.js';
3
4
  export { toMatchScreenshots } from './to-match-screenshots.js';
4
- import './get-screenshot-paths-BhXNedbs.js';
5
- import './request-B60Gnj7P.js';
6
5
  import 'playwright';
7
6
  import 'zod';
7
+ import './get-screenshot-paths-BhXNedbs.js';
8
8
  import './image-diff-DwK_Ui8E.js';
9
9
  import 'jest-image-snapshot';
10
+
11
+ interface CreateScreenshotTitlePromptOptions {
12
+ /**
13
+ * Maximum number of characters allowed in the returned title.
14
+ *
15
+ * @default 80
16
+ */
17
+ maxTitleLength?: number;
18
+ /**
19
+ * Fallback title the model should use when input is too sparse.
20
+ *
21
+ * @default 'Should render correctly.'
22
+ */
23
+ fallbackTitle?: string;
24
+ /**
25
+ * Whether the generated title should include the browser type when useful.
26
+ *
27
+ * @default true
28
+ */
29
+ includeBrowserType?: boolean;
30
+ /**
31
+ * Whether the generated title can include the story id.
32
+ *
33
+ * @default false
34
+ */
35
+ includeStoryId?: boolean;
36
+ }
37
+ /**
38
+ * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
39
+ *
40
+ * The prompt enforces JSON-only output in the form:
41
+ * `{"title":"..."}`.
42
+ */
43
+ declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
44
+
45
+ export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
- 'use strict';var C=require('fs'),jsonfile=require('jsonfile'),P=require('path'),Fe=require('lodash/kebabCase'),it=require('join-images'),rt=require('sharp'),router=require('@storybook/core/router'),ue=require('normalize-url'),objectPathImmutable=require('object-path-immutable');require('@pixpilot/dom'),require('@storybook/components'),require('@storybook/icons'),require('react'),require('@pixpilot/hash'),require('sonner');var nt=require('fast-glob'),nanoid=require('nanoid'),lt=require('p-limit'),diffSnapshot=require('jest-image-snapshot/src/diff-snapshot'),jestImageSnapshot=require('jest-image-snapshot');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var C__namespace=/*#__PURE__*/_interopNamespace(C);var P__namespace=/*#__PURE__*/_interopNamespace(P);var Fe__default=/*#__PURE__*/_interopDefault(Fe);var it__default=/*#__PURE__*/_interopDefault(it);var rt__default=/*#__PURE__*/_interopDefault(rt);var ue__default=/*#__PURE__*/_interopDefault(ue);var nt__default=/*#__PURE__*/_interopDefault(nt);var lt__default=/*#__PURE__*/_interopDefault(lt);async function O(e,t,o=true){return new Promise((s,i)=>{if(!C__namespace.default.existsSync(e)){if(!o){s(void 0);return}s(t==="*"?{stories:{}}:{stories:{[t]:{}}});return}jsonfile.readFile(e,(r,n)=>{if(r){i(r);return}let a=n||{stories:{}};a.stories||(a.stories={}),!a.stories[t]&&t!=="*"&&(a.stories[t]={}),s(a);});})}async function W(e){let t=await O(e,"*")||{stories:{}},o=t.stories||{},i=Object.keys(o).map(r=>({data:o[r],storyId:r}));return {playWrightData:t,storyData:i}}function A(e){let t=P__namespace.resolve(e),o=P__namespace.parse(t),s=o.ext===".json"?`${o.name}.json`:`${o.name}.playwright.json`;return {dir:o.dir,name:s,path:P__namespace.join(P__namespace.dirname(t),s),screenShotsDir:P__namespace.join(o.dir,"__screenshots__")}}function E(e){let t=A(e.filePath),o=Fe__default.default(`${P__namespace.default.basename(e.storyId)}--${e.title}--${e.browserType}`),s=P__namespace.default.join(t.screenShotsDir,"__diff_output__"),i=P__namespace.default.join(t.screenShotsDir,`${o}-snap.png`);return {diffDir:s,filePath:i,screenshotIdentifier:o,screenshotsDir:t.screenShotsDir}}async function Q(e,t={}){let{blur:o,timeout:s}=t;await this.fill(e,""),o&&await this.$eval(e,i=>i.blur()),s&&await this.waitForTimeout(s);}async function q(e,t){await e.waitForSelector(t);let o=await e.$(t);if(!o)throw new Error("Unable to find selector!");let s=await o.boundingBox();if(!s)throw new Error("Unable to get boundingBox!");return s}function S(e,t,o){return !o||!o[t]?e:o[t]}async function G(e,t,o,s){let{steps:i=1,skipMouseUp:r}=s||{},n=await q(this,e),a=S(n.width/2,"x",o),p=S(n.height/2,"y",o),c=S(0,"x",t),l=S(0,"y",t);await this.mouse.move(n.x+a,n.y+p,{steps:i}),await this.mouse.down(),await this.mouse.move(c,l,{steps:i}),r||await this.mouse.up();}async function x(e,t,o,s,i,r,n){await e.$eval(o,(a,p)=>{let c=a.getBoundingClientRect(),{client:l={},page:u={},screen:g={},type:b,options:f}=p,m=new Touch({clientX:l.x,clientY:l.y,identifier:Date.now(),pageX:u.x||(l.x!==void 0?c.left+l.x:void 0),pageY:u.y||(l.y!==void 0?c.top+l.y:void 0),screenX:g.x,screenY:g.y,target:a}),h=new TouchEvent(b,{bubbles:true,cancelable:true,...f,changedTouches:[m],targetTouches:[m],touches:[m]});return a.dispatchEvent(h)},{client:r,options:n,page:s,screen:i,type:t});}async function J(e,t,o,s,i,r,n,a){await x(this,"touchstart",e,t,r,s,a),await x(this,"touchmove",e,o,n,i,a),await x(this,"touchend",e,o,n,i,a);}function ee(e){let t=e;return t.dragDropSelector=G,t.scrollSelector=ie,t.mouseDownOnSelector=te,t.mouseMoveToSelector=se,t.setSelectorSize=ne,t.clearInput=Q,t.selectorMouseWheel=re,t.touchCancel=ae,t.touchMove=ce,t.touchEnd=pe,t.touchStart=le,t.touchFromTo=J,t.mouseFromTo=oe,t}async function te(e,t,o){let{steps:s=1}=o||{},i=await q(this,e),r=S(i.width/2,"x",t),n=S(i.height/2,"y",t);await this.mouse.move(i.x+r,i.y+n,{steps:s}),await this.mouse.down();}async function oe(e,t,o){let{skipMouseUp:s,steps:i=1}=o||{};if(e.x===void 0||e.y===void 0||t.x===void 0||t.y===void 0)throw new Error("mouseFromTo requires from/to coordinates (x and y).");await this.mouse.move(e.x,e.y,{steps:i}),await this.mouse.down(),await this.mouse.move(t.x,t.y,{steps:i}),s||await this.mouse.up();}async function se(e,t,o){let{steps:s=1}=o||{},i=await q(this,e),r=S(i.width/2,"x",t),n=S(i.height/2,"y",t);await this.mouse.move(i.x+r,i.y+n,{steps:s});}async function ie(e,t){return await this.waitForSelector(e),await this.$eval(e,(s,i)=>{i.top&&(s.scrollTop=i.top),i.left&&(s.scrollLeft=i.left);},t)}async function re(e,t){return await this.waitForSelector(e),await this.$eval(e,(s,i)=>{let r=new WheelEvent("wheel",i);s.dispatchEvent(r);},t)}async function ne(e,t,o){await this.$eval(e,(s,i)=>{i.width!==void 0&&(s.style.width=i.width),i.height!==void 0&&(s.style.height=i.height);},{height:o,width:t});}async function ae(e,t,o,s,i){await x(this,"touchcancel",e,t,o,s,i);}async function pe(e,t,o,s,i){await x(this,"touchend",e,t,o,s,i);}async function ce(e,t,o,s,i){await x(this,"touchmove",e,t,o,s,i);}async function le(e,t,o,s,i){await x(this,"touchstart",e,t,o,s,i);}function R(e){return !e||Object.keys(e).length===0?"":router.buildArgsParam({},e)}function de(e){return R(e)}function he(e){return R(e)}function me(e){if(!e)return "";let o=Object.keys(e).map(s=>{let i=e[s];return Array.isArray(i)?i.length>0&&typeof i[0]=="object"?`knob-${s}=${JSON.stringify(i)}`:`knob-${s}=${i.join(",")}`:typeof i=="object"?`knob-${s}=${JSON.stringify(i)}`:`knob-${s}=${i}`});return encodeURI(o.join("&"))}function fe(e,t,o,s,i){let r;/^\.{0,2}[/\\]/.test(e)?r=`file:///${e.replace(/\\/g,"/").replace(/^\/+/,"")}`:/^https?:\/\//i.test(e)||/^file:\/\//i.test(e)?r=ue__default.default(e):r=ue__default.default(`http://${e}`);let n=`${r}/iframe.html?id=${t}`,a=de(s);a&&(n=`${n}&args=${a}`);let p=he(i);if(p&&(n=`${n}&globals=${p}`),o){let c=me(o);c&&(n=`${n}&${c}`);}return n.replace(/\\/g,"/")}function L(e,t){if(!t)return;let o=t.split(".").join(".properties.");return objectPathImmutable.get(e,o)}function ge(e,t){let o=L(t,e.name);if(!o)throw new Error(`Unable to find '${e.name}', possibly this action has deprecated/removed from playwright and or from custom definitions.`);let s=o.parameters||{};return Object.keys(s).reduce((r,n)=>{let a=o.required&&o.required.includes(n);if(e&&e.args&&e.args[n]!==void 0){let p=e.args[n];if(!a&&p!==null&&(p===void 0||typeof p=="object"&&Object.keys(p).length===0||Array.isArray(p)&&p.length===0))return r;r.push(e.args[n]);}else r.push(void 0);return r},[])}function F(...e){for(let t=0;t<e.length;t++){let o=e[t];if(o&&Object.keys(o).length>0)return o}}var U=e=>{if(e)return F(e.globals)};var B=e=>{if(e)return F(e.args,e.props)};function tt(e,t){let o=L(e,t.name);if(!o||!o.required||!o.required.length)return {};if(!t.args)return {required:o.required};if(Object.keys(t.args).length===0)return {required:o.required};let i=[];for(let r=0;r<o.required.length;r++){let n=o.required[r];t.args[n]||i.push(n);}return {required:i.length===0?void 0:i}}function ve(e,t){return tt(e,t).required===void 0}function k(){throw new Error("Configuration has not been set.");}var ke={clearInput:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},options:{type:"object",properties:{timeout:{type:"number"},blur:{type:"boolean"}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, waits for actionability checks, focuses the element, clear it and triggers an input event. If the element matching selector is not an <input>, <textarea> or [contenteditable] element, this method throws an error."},dragDropSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},to:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},mouseDownRelativeToSelector:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1},skipMouseUp:{type:"boolean"}},additionalProperties:false}},required:["selector","to"],description:"This method fetches an element with `selector`, and move it to the position given by user. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},mouseFromTo:{kind:"function",type:"Promise",parameters:{from:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},to:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1},skipMouseUp:{type:"boolean"}},additionalProperties:false}},required:["from","to"],description:"This method will perform mouse down, move,and up from to selected location."},scrollSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},scrollProperty:{type:"object",properties:{top:{type:"number"},left:{type:"number"}},additionalProperties:false}},required:["selector","scrollProperty"],description:"This method fetches an element with `selector`, and set the selector scrollLeft and scrollTop. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},mouseDownOnSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},point:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and perform mousedown on the center of selector. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},mouseMoveToSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},point:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and move the mouse to center of selector. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},setSelectorSize:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},width:{type:"string"},height:{type:"string"}},required:["selector"],description:"This method fetches an element with `selector`, set the height and with. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},selectorMouseWheel:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},eventInitDict:{type:"object",properties:{deltaMode:{type:"number"},deltaX:{type:"number"},deltaY:{type:"number"},deltaZ:{type:"number"}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch WheelEvent. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchStart:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchstart event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchMove:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchmove event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchEnd:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchend event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchCancel:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchcancel event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchFromTo:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},pageFrom:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},pageTo:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},clientFrom:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},clientTo:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screenFrom:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screenTo:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchstart,touchmove and touchend event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},waitForSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to query for."},options:{type:"object",properties:{state:{type:"string",enum:["attached","detached","visible","hidden"],description:"Defaults to `'visible'`. Can be either:\n- `'attached'` - wait for element to be present in DOM.\n- `'detached'` - wait for element to not be present in DOM.\n- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible.\n- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`. This is opposite to the `'visible'` option."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","options"],description:"**NOTE** Use web assertions that assert visibility or a locator-based [locator.waitFor([options])](https://playwright.dev/docs/api/class-locator#locator-wait-for) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nReturns when element specified by selector satisfies [`state`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-state) option. Returns `null` if waiting for `hidden` or `detached`.\n\n**NOTE** Playwright automatically waits for element to be ready before performing an action. Using [Locator](https://playwright.dev/docs/api/class-locator) objects and web-first assertions makes the code wait-for-selector-free.\n\nWait for the [`selector`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-selector) to satisfy [`state`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-state) option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method [`selector`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-selector) already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the [`timeout`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-timeout) milliseconds, the function will throw.\n\n**Usage**\n\nThis method works across navigations:\n\n```js const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.\n\n(async () => { const browser = await chromium.launch(); const page = await browser.newPage(); for (const currentURL of ['https://google.com', 'https://bbc.com']) { await page.goto(currentURL); const element = await page.waitForSelector('img'); console.log('Loaded image: ' + await element.getAttribute('src')); } await browser.close(); })(); ```"},check:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.check([options])](https://playwright.dev/docs/api/class-locator#locator-check) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method checks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-check-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-check-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-check-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to click in the center of the element. 1. Ensure that the element is now checked. If not, this method throws.\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-check-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},click:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."},force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},modifiers:{type:"array",items:{type:"string",enum:["Alt","Control","ControlOrMeta","Meta","Shift"]},description:'Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows and Linux and to "Meta" on macOS.'},noWaitAfter:{type:"boolean",description:"Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.",deprecated:"This option will default to `true` in the future."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys are pressed."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.click([options])](https://playwright.dev/docs/api/class-locator#locator-click) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method clicks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-click-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-click-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-click-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to click in the center of the element, or the specified [`position`](https://playwright.dev/docs/api/class-page#page-click-option-position). 1. Wait for initiated navigations to either succeed or fail, unless [`noWaitAfter`](https://playwright.dev/docs/api/class-page#page-click-option-no-wait-after) option is set.\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-click-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},dblclick:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."},force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},modifiers:{type:"array",items:{type:"string",enum:["Alt","Control","ControlOrMeta","Meta","Shift"]},description:'Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows and Linux and to "Meta" on macOS.'},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys are pressed."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.dblclick([options])](https://playwright.dev/docs/api/class-locator#locator-dblclick) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method double clicks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-dblclick-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-dblclick-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-dblclick-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to double click in the center of the element, or the specified [`position`](https://playwright.dev/docs/api/class-page#page-dblclick-option-position).\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-dblclick-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this.\n\n**NOTE** `page.dblclick()` dispatches two `click` events and a single `dblclick` event."},fill:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},value:{type:"string",description:"Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","value"],description:"**NOTE** Use locator-based [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method waits for an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-fill-option-selector), waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.\n\nIf the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.\n\nTo send fine-grained keyboard events, use [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially)."},focus:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.focus([options])](https://playwright.dev/docs/api/class-locator#locator-focus) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method fetches an element with [`selector`](https://playwright.dev/docs/api/class-page#page-focus-option-selector) and focuses it. If there's no element matching [`selector`](https://playwright.dev/docs/api/class-page#page-focus-option-selector), the method waits until a matching element appears in the DOM."},hover:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},modifiers:{type:"array",items:{type:"string",enum:["Alt","Control","ControlOrMeta","Meta","Shift"]},description:'Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows and Linux and to "Meta" on macOS.'},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys are pressed."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.hover([options])](https://playwright.dev/docs/api/class-locator#locator-hover) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method hovers over an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-hover-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-hover-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-hover-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to hover over the center of the element, or the specified [`position`](https://playwright.dev/docs/api/class-page#page-hover-option-position).\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-hover-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},press:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0."},noWaitAfter:{type:"boolean",description:"Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.",deprecated:"This option will default to `true` in the future."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","key"],description:"**NOTE** Use locator-based [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nFocuses the element, and then uses [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down) and [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up).\n\n[`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the [`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:\n\n`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.\n\nFollowing modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`. `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.\n\nHolding down `Shift` will type the text that corresponds to the [`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) in the upper case.\n\nIf [`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.\n\nShortcuts such as `key: \"Control+o\"`, `key: \"Control++` or `key: \"Control+Shift+T\"` are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.\n\n**Usage**\n\n```js const page = await browser.newPage(); await page.goto('https://keycode.info'); await page.press('body', 'A'); await page.screenshot({ path: 'A.png' }); await page.press('body', 'ArrowLeft'); await page.screenshot({ path: 'ArrowLeft.png' }); await page.press('body', 'Shift+O'); await page.screenshot({ path: 'O.png' }); await browser.close(); ```"},type:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},text:{type:"string",description:"A text to type into a focused element."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between key presses in milliseconds. Defaults to 0."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","text"],description:"Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send fine-grained keyboard events. To fill values in form fields, use [page.fill(selector, value[, options])](https://playwright.dev/docs/api/class-page#page-fill).\n\nTo press a special key, like `Control` or `ArrowDown`, use [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press).\n\n**Usage**",deprecated:`In most cases, you should use
1
+ 'use strict';var M=require('fs'),jsonfile=require('jsonfile'),P=require('path'),Ne=require('lodash/kebabCase'),pt=require('join-images'),ct=require('sharp'),router=require('@storybook/core/router'),fe=require('normalize-url'),objectPathImmutable=require('object-path-immutable');require('@pixpilot/dom'),require('@storybook/components'),require('@storybook/icons'),require('react'),require('@pixpilot/hash'),require('sonner');var lt=require('fast-glob'),nanoid=require('nanoid'),mt=require('p-limit'),diffSnapshot=require('jest-image-snapshot/src/diff-snapshot'),jestImageSnapshot=require('jest-image-snapshot');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var M__namespace=/*#__PURE__*/_interopNamespace(M);var P__namespace=/*#__PURE__*/_interopNamespace(P);var Ne__default=/*#__PURE__*/_interopDefault(Ne);var pt__default=/*#__PURE__*/_interopDefault(pt);var ct__default=/*#__PURE__*/_interopDefault(ct);var fe__default=/*#__PURE__*/_interopDefault(fe);var lt__default=/*#__PURE__*/_interopDefault(lt);var mt__default=/*#__PURE__*/_interopDefault(mt);var L={fallbackTitle:"Should render correctly.",includeBrowserType:true,includeStoryId:false,maxTitleLength:80},We=2,Fe=10;function Ue(e={}){let t=Number.isFinite(e.maxTitleLength)?Math.max(Fe,Math.floor(e.maxTitleLength)):L.maxTitleLength;return {fallbackTitle:typeof e.fallbackTitle=="string"&&e.fallbackTitle.trim()?e.fallbackTitle.trim():L.fallbackTitle,includeBrowserType:e.includeBrowserType??L.includeBrowserType,includeStoryId:e.includeStoryId??L.includeStoryId,maxTitleLength:t}}function bt(e,t){let o=Ue(t),s=JSON.stringify(e,null,We);return ["You are a screenshot title generator for Storybook Playwright.","Your goal is to read the input JSON and produce one clear screenshot title.","","Follow this process internally before writing the final answer:","1) Parse INPUT_JSON as JSON.","2) Review every top-level and nested field and understand what each field says about the screenshot context.","3) Decide the most important details for naming this screenshot.","4) Build a short, human-friendly title.","","Field guide:","- story.name: story display name.","- story.title: Storybook group/title path.","- story.changedArgs: args changed from defaults; high-priority signal for title.","- story.initialArgs: default args for the story; use for context only.","- story.argTypes: arg metadata; use only when it clarifies changedArgs.","- story.parameters: Storybook-level metadata; only use if it impacts screenshot meaning.","- story.filePath: source story file path.","- story.id: unique Storybook story id.","- browser.type: browser engine (chromium, firefox, webkit).","- browser.options: browser/device options such as viewport and device profile.","- screenshotOptions: screenshot behavior options that may change output meaning.","","Title rules:",`- Maximum length: ${o.maxTitleLength} characters.`,`- ${o.includeBrowserType?"Include browser type only when it adds useful context.":"Do not include browser type in the title."}`,`- ${o.includeStoryId?"You may include story.id when needed for uniqueness.":"Do not include story.id unless no other unique context exists."}`,"- Prefer changedArgs details when present.","- Avoid filler words and generic phrases.","- Title must be plain text (no markdown, no quotes around the full title).","","Output contract (strict):","- Return JSON only.","- Return exactly one object with exactly one key: title.",'- Shape: {"title":"<generated title>"}',`- If context is insufficient, use fallback title: ${JSON.stringify(o.fallbackTitle)}`,"","INPUT_JSON:",s].join(`
2
+ `)}async function O(e,t,o=true){return new Promise((s,i)=>{if(!M__namespace.default.existsSync(e)){if(!o){s(void 0);return}s(t==="*"?{stories:{}}:{stories:{[t]:{}}});return}jsonfile.readFile(e,(r,n)=>{if(r){i(r);return}let a=n||{stories:{}};a.stories||(a.stories={}),!a.stories[t]&&t!=="*"&&(a.stories[t]={}),s(a);});})}async function R(e){let t=await O(e,"*")||{stories:{}},o=t.stories||{},i=Object.keys(o).map(r=>({data:o[r],storyId:r}));return {playWrightData:t,storyData:i}}function A(e){let t=P__namespace.resolve(e),o=P__namespace.parse(t),s=o.ext===".json"?`${o.name}.json`:`${o.name}.playwright.json`;return {dir:o.dir,name:s,path:P__namespace.join(P__namespace.dirname(t),s),screenShotsDir:P__namespace.join(o.dir,"__screenshots__")}}function E(e){let t=A(e.filePath),o=Ne__default.default(`${P__namespace.default.basename(e.storyId)}--${e.title}--${e.browserType}`),s=P__namespace.default.join(t.screenShotsDir,"__diff_output__"),i=P__namespace.default.join(t.screenShotsDir,`${o}-snap.png`);return {diffDir:s,filePath:i,screenshotIdentifier:o,screenshotsDir:t.screenShotsDir}}async function G(e,t={}){let{blur:o,timeout:s}=t;await this.fill(e,""),o&&await this.$eval(e,i=>i.blur()),s&&await this.waitForTimeout(s);}async function q(e,t){await e.waitForSelector(t);let o=await e.$(t);if(!o)throw new Error("Unable to find selector!");let s=await o.boundingBox();if(!s)throw new Error("Unable to get boundingBox!");return s}function S(e,t,o){return !o||!o[t]?e:o[t]}async function J(e,t,o,s){let{steps:i=1,skipMouseUp:r}=s||{},n=await q(this,e),a=S(n.width/2,"x",o),p=S(n.height/2,"y",o),c=S(0,"x",t),l=S(0,"y",t);await this.mouse.move(n.x+a,n.y+p,{steps:i}),await this.mouse.down(),await this.mouse.move(c,l,{steps:i}),r||await this.mouse.up();}async function x(e,t,o,s,i,r,n){await e.$eval(o,(a,p)=>{let c=a.getBoundingClientRect(),{client:l={},page:m={},screen:y={},type:w,options:f}=p,u=new Touch({clientX:l.x,clientY:l.y,identifier:Date.now(),pageX:m.x||(l.x!==void 0?c.left+l.x:void 0),pageY:m.y||(l.y!==void 0?c.top+l.y:void 0),screenX:y.x,screenY:y.y,target:a}),h=new TouchEvent(w,{bubbles:true,cancelable:true,...f,changedTouches:[u],targetTouches:[u],touches:[u]});return a.dispatchEvent(h)},{client:r,options:n,page:s,screen:i,type:t});}async function ee(e,t,o,s,i,r,n,a){await x(this,"touchstart",e,t,r,s,a),await x(this,"touchmove",e,o,n,i,a),await x(this,"touchend",e,o,n,i,a);}function te(e){let t=e;return t.dragDropSelector=J,t.scrollSelector=re,t.mouseDownOnSelector=oe,t.mouseMoveToSelector=ie,t.setSelectorSize=ae,t.clearInput=G,t.selectorMouseWheel=ne,t.touchCancel=pe,t.touchMove=le,t.touchEnd=ce,t.touchStart=de,t.touchFromTo=ee,t.mouseFromTo=se,t}async function oe(e,t,o){let{steps:s=1}=o||{},i=await q(this,e),r=S(i.width/2,"x",t),n=S(i.height/2,"y",t);await this.mouse.move(i.x+r,i.y+n,{steps:s}),await this.mouse.down();}async function se(e,t,o){let{skipMouseUp:s,steps:i=1}=o||{};if(e.x===void 0||e.y===void 0||t.x===void 0||t.y===void 0)throw new Error("mouseFromTo requires from/to coordinates (x and y).");await this.mouse.move(e.x,e.y,{steps:i}),await this.mouse.down(),await this.mouse.move(t.x,t.y,{steps:i}),s||await this.mouse.up();}async function ie(e,t,o){let{steps:s=1}=o||{},i=await q(this,e),r=S(i.width/2,"x",t),n=S(i.height/2,"y",t);await this.mouse.move(i.x+r,i.y+n,{steps:s});}async function re(e,t){return await this.waitForSelector(e),await this.$eval(e,(s,i)=>{i.top&&(s.scrollTop=i.top),i.left&&(s.scrollLeft=i.left);},t)}async function ne(e,t){return await this.waitForSelector(e),await this.$eval(e,(s,i)=>{let r=new WheelEvent("wheel",i);s.dispatchEvent(r);},t)}async function ae(e,t,o){await this.$eval(e,(s,i)=>{i.width!==void 0&&(s.style.width=i.width),i.height!==void 0&&(s.style.height=i.height);},{height:o,width:t});}async function pe(e,t,o,s,i){await x(this,"touchcancel",e,t,o,s,i);}async function ce(e,t,o,s,i){await x(this,"touchend",e,t,o,s,i);}async function le(e,t,o,s,i){await x(this,"touchmove",e,t,o,s,i);}async function de(e,t,o,s,i){await x(this,"touchstart",e,t,o,s,i);}function W(e){return !e||Object.keys(e).length===0?"":router.buildArgsParam({},e)}function he(e){return W(e)}function ue(e){return W(e)}function me(e){if(!e)return "";let o=Object.keys(e).map(s=>{let i=e[s];return Array.isArray(i)?i.length>0&&typeof i[0]=="object"?`knob-${s}=${JSON.stringify(i)}`:`knob-${s}=${i.join(",")}`:typeof i=="object"?`knob-${s}=${JSON.stringify(i)}`:`knob-${s}=${i}`});return encodeURI(o.join("&"))}function ye(e,t,o,s,i){let r;/^\.{0,2}[/\\]/.test(e)?r=`file:///${e.replace(/\\/g,"/").replace(/^\/+/,"")}`:/^https?:\/\//i.test(e)||/^file:\/\//i.test(e)?r=fe__default.default(e):r=fe__default.default(`http://${e}`);let n=`${r}/iframe.html?id=${t}`,a=he(s);a&&(n=`${n}&args=${a}`);let p=ue(i);if(p&&(n=`${n}&globals=${p}`),o){let c=me(o);c&&(n=`${n}&${c}`);}return n.replace(/\\/g,"/")}function F(e,t){if(!t)return;let o=t.split(".").join(".properties.");return objectPathImmutable.get(e,o)}function ge(e,t){let o=F(t,e.name);if(!o)throw new Error(`Unable to find '${e.name}', possibly this action has deprecated/removed from playwright and or from custom definitions.`);let s=o.parameters||{};return Object.keys(s).reduce((r,n)=>{let a=o.required&&o.required.includes(n);if(e&&e.args&&e.args[n]!==void 0){let p=e.args[n];if(!a&&p!==null&&(p===void 0||typeof p=="object"&&Object.keys(p).length===0||Array.isArray(p)&&p.length===0))return r;r.push(e.args[n]);}else r.push(void 0);return r},[])}function U(...e){for(let t=0;t<e.length;t++){let o=e[t];if(o&&Object.keys(o).length>0)return o}}var B=e=>{if(e)return U(e.globals)};var _=e=>{if(e)return U(e.args,e.props)};function rt(e,t){let o=F(e,t.name);if(!o||!o.required||!o.required.length)return {};if(!t.args)return {required:o.required};if(Object.keys(t.args).length===0)return {required:o.required};let i=[];for(let r=0;r<o.required.length;r++){let n=o.required[r];t.args[n]||i.push(n);}return {required:i.length===0?void 0:i}}function xe(e,t){return rt(e,t).required===void 0}function k(){throw new Error("Configuration has not been set.");}var Se={clearInput:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},options:{type:"object",properties:{timeout:{type:"number"},blur:{type:"boolean"}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, waits for actionability checks, focuses the element, clear it and triggers an input event. If the element matching selector is not an <input>, <textarea> or [contenteditable] element, this method throws an error."},dragDropSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},to:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},mouseDownRelativeToSelector:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1},skipMouseUp:{type:"boolean"}},additionalProperties:false}},required:["selector","to"],description:"This method fetches an element with `selector`, and move it to the position given by user. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},mouseFromTo:{kind:"function",type:"Promise",parameters:{from:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},to:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1},skipMouseUp:{type:"boolean"}},additionalProperties:false}},required:["from","to"],description:"This method will perform mouse down, move,and up from to selected location."},scrollSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},scrollProperty:{type:"object",properties:{top:{type:"number"},left:{type:"number"}},additionalProperties:false}},required:["selector","scrollProperty"],description:"This method fetches an element with `selector`, and set the selector scrollLeft and scrollTop. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},mouseDownOnSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},point:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and perform mousedown on the center of selector. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},mouseMoveToSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},point:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{steps:{type:"number",default:1}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and move the mouse to center of selector. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},setSelectorSize:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},width:{type:"string"},height:{type:"string"}},required:["selector"],description:"This method fetches an element with `selector`, set the height and with. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},selectorMouseWheel:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},eventInitDict:{type:"object",properties:{deltaMode:{type:"number"},deltaX:{type:"number"},deltaY:{type:"number"},deltaZ:{type:"number"}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch WheelEvent. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchStart:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchstart event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchMove:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchmove event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchEnd:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchend event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchCancel:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},page:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screen:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},client:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchcancel event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},touchFromTo:{kind:"function",type:"Promise",parameters:{selector:{type:"string"},pageFrom:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},pageTo:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},clientFrom:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},clientTo:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screenFrom:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},screenTo:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},additionalProperties:false},options:{type:"object",properties:{bubbles:{type:"boolean",default:true},cancelable:{type:"boolean",default:true}},additionalProperties:false}},required:["selector"],description:"This method fetches an element with `selector`, and dispatch touchstart,touchmove and touchend event. If there's no element matching `selector`, the method waits until a matching element appears in the DOM."},waitForSelector:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to query for."},options:{type:"object",properties:{state:{type:"string",enum:["attached","detached","visible","hidden"],description:"Defaults to `'visible'`. Can be either:\n- `'attached'` - wait for element to be present in DOM.\n- `'detached'` - wait for element to not be present in DOM.\n- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible.\n- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`. This is opposite to the `'visible'` option."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","options"],description:"**NOTE** Use web assertions that assert visibility or a locator-based [locator.waitFor([options])](https://playwright.dev/docs/api/class-locator#locator-wait-for) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nReturns when element specified by selector satisfies [`state`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-state) option. Returns `null` if waiting for `hidden` or `detached`.\n\n**NOTE** Playwright automatically waits for element to be ready before performing an action. Using [Locator](https://playwright.dev/docs/api/class-locator) objects and web-first assertions makes the code wait-for-selector-free.\n\nWait for the [`selector`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-selector) to satisfy [`state`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-state) option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method [`selector`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-selector) already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the [`timeout`](https://playwright.dev/docs/api/class-page#page-wait-for-selector-option-timeout) milliseconds, the function will throw.\n\n**Usage**\n\nThis method works across navigations:\n\n```js const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.\n\n(async () => { const browser = await chromium.launch(); const page = await browser.newPage(); for (const currentURL of ['https://google.com', 'https://bbc.com']) { await page.goto(currentURL); const element = await page.waitForSelector('img'); console.log('Loaded image: ' + await element.getAttribute('src')); } await browser.close(); })(); ```"},check:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.check([options])](https://playwright.dev/docs/api/class-locator#locator-check) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method checks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-check-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-check-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-check-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to click in the center of the element. 1. Ensure that the element is now checked. If not, this method throws.\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-check-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},click:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."},force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},modifiers:{type:"array",items:{type:"string",enum:["Alt","Control","ControlOrMeta","Meta","Shift"]},description:'Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows and Linux and to "Meta" on macOS.'},noWaitAfter:{type:"boolean",description:"Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.",deprecated:"This option will default to `true` in the future."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys are pressed."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.click([options])](https://playwright.dev/docs/api/class-locator#locator-click) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method clicks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-click-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-click-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-click-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to click in the center of the element, or the specified [`position`](https://playwright.dev/docs/api/class-page#page-click-option-position). 1. Wait for initiated navigations to either succeed or fail, unless [`noWaitAfter`](https://playwright.dev/docs/api/class-page#page-click-option-no-wait-after) option is set.\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-click-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},dblclick:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."},force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},modifiers:{type:"array",items:{type:"string",enum:["Alt","Control","ControlOrMeta","Meta","Shift"]},description:'Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows and Linux and to "Meta" on macOS.'},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys are pressed."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.dblclick([options])](https://playwright.dev/docs/api/class-locator#locator-dblclick) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method double clicks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-dblclick-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-dblclick-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-dblclick-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to double click in the center of the element, or the specified [`position`](https://playwright.dev/docs/api/class-page#page-dblclick-option-position).\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-dblclick-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this.\n\n**NOTE** `page.dblclick()` dispatches two `click` events and a single `dblclick` event."},fill:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},value:{type:"string",description:"Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","value"],description:"**NOTE** Use locator-based [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method waits for an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-fill-option-selector), waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.\n\nIf the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.\n\nTo send fine-grained keyboard events, use [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially)."},focus:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.focus([options])](https://playwright.dev/docs/api/class-locator#locator-focus) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method fetches an element with [`selector`](https://playwright.dev/docs/api/class-page#page-focus-option-selector) and focuses it. If there's no element matching [`selector`](https://playwright.dev/docs/api/class-page#page-focus-option-selector), the method waits until a matching element appears in the DOM."},hover:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},modifiers:{type:"array",items:{type:"string",enum:["Alt","Control","ControlOrMeta","Meta","Shift"]},description:'Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows and Linux and to "Meta" on macOS.'},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys are pressed."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.hover([options])](https://playwright.dev/docs/api/class-locator#locator-hover) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method hovers over an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-hover-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-hover-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-hover-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to hover over the center of the element, or the specified [`position`](https://playwright.dev/docs/api/class-page#page-hover-option-position).\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-hover-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},press:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0."},noWaitAfter:{type:"boolean",description:"Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`.",deprecated:"This option will default to `true` in the future."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","key"],description:"**NOTE** Use locator-based [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nFocuses the element, and then uses [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down) and [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up).\n\n[`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the [`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:\n\n`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.\n\nFollowing modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`. `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.\n\nHolding down `Shift` will type the text that corresponds to the [`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) in the upper case.\n\nIf [`key`](https://playwright.dev/docs/api/class-page#page-press-option-key) is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.\n\nShortcuts such as `key: \"Control+o\"`, `key: \"Control++` or `key: \"Control+Shift+T\"` are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.\n\n**Usage**\n\n```js const page = await browser.newPage(); await page.goto('https://keycode.info'); await page.press('body', 'A'); await page.screenshot({ path: 'A.png' }); await page.press('body', 'ArrowLeft'); await page.screenshot({ path: 'ArrowLeft.png' }); await page.press('body', 'Shift+O'); await page.screenshot({ path: 'O.png' }); await browser.close(); ```"},type:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},text:{type:"string",description:"A text to type into a focused element."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between key presses in milliseconds. Defaults to 0."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."}},additionalProperties:false}},required:["selector","text"],description:"Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send fine-grained keyboard events. To fill values in form fields, use [page.fill(selector, value[, options])](https://playwright.dev/docs/api/class-page#page-fill).\n\nTo press a special key, like `Control` or `ArrowDown`, use [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press).\n\n**Usage**",deprecated:`In most cases, you should use
2
3
  [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. You only need
3
4
  to press keys one by one if there is special keyboard handling on the page - in this case use
4
- [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).`},uncheck:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.uncheck([options])](https://playwright.dev/docs/api/class-locator#locator-uncheck) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method unchecks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-uncheck-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-uncheck-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked, this method returns immediately. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-uncheck-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to click in the center of the element. 1. Ensure that the element is now unchecked. If not, this method throws.\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-uncheck-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},waitForTimeout:{kind:"function",type:"Promise",parameters:{timeout:{type:"number",description:"A timeout to wait for"}},required:["timeout"],description:"**NOTE** Never wait for timeout in production. Tests that wait for time are inherently flaky. Use [Locator](https://playwright.dev/docs/api/class-locator) actions and web assertions that wait automatically.\n\nWaits for the given [`timeout`](https://playwright.dev/docs/api/class-page#page-wait-for-timeout-option-timeout) in milliseconds.\n\nNote that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be flaky. Use signals such as network events, selectors becoming visible and others instead.\n\n**Usage**\n\n```js // wait for 1 second await page.waitForTimeout(1000); ```"},keyboard:{type:"object",properties:{down:{kind:"function",type:"Promise",parameters:{key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."}},required:["key"],description:"Dispatches a `keydown` event.\n\n[`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:\n\n`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.\n\nFollowing modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`. `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.\n\nHolding down `Shift` will type the text that corresponds to the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) in the upper case.\n\nIf [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.\n\nIf [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier active. To release the modifier key, use [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up).\n\nAfter the key is pressed once, subsequent calls to [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down) will have [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up).\n\n**NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case."},insertText:{kind:"function",type:"Promise",parameters:{text:{type:"string",description:"Sets input to the specified text value."}},required:["text"],description:"Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.\n\n**Usage**\n\n```js page.keyboard.insertText('\u55E8'); ```\n\n**NOTE** Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case."},press:{kind:"function",type:"Promise",parameters:{key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["key"],description:"**NOTE** In most cases, you should use [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press) instead.\n\n[`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:\n\n`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.\n\nFollowing modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`. `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.\n\nHolding down `Shift` will type the text that corresponds to the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) in the upper case.\n\nIf [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.\n\nShortcuts such as `key: \"Control+o\"`, `key: \"Control++` or `key: \"Control+Shift+T\"` are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.\n\n**Usage**\n\n```js const page = await browser.newPage(); await page.goto('https://keycode.info'); await page.keyboard.press('A'); await page.screenshot({ path: 'A.png' }); await page.keyboard.press('ArrowLeft'); await page.screenshot({ path: 'ArrowLeft.png' }); await page.keyboard.press('Shift+O'); await page.screenshot({ path: 'O.png' }); await browser.close(); ```\n\nShortcut for [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down) and [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up)."},type:{kind:"function",type:"Promise",parameters:{text:{type:"string",description:"A text to type into a focused element."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between key presses in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["text"],description:"**NOTE** In most cases, you should use [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).\n\nSends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.\n\nTo press a special key, like `Control` or `ArrowDown`, use [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press).\n\n**Usage**\n\n```js await page.keyboard.type('Hello'); // Types instantly await page.keyboard.type('World', { delay: 100 }); // Types slower, like a user ```\n\n**NOTE** Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.\n\n**NOTE** For characters that are not on a US keyboard, only an `input` event will be sent."},up:{kind:"function",type:"Promise",parameters:{key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."}},required:["key"],description:"Dispatches a `keyup` event."}},required:["down","insertText","press","type","up"],additionalProperties:false,description:"Keyboard provides an api for managing a virtual keyboard. The high level api is [keyboard.type(text[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-type), which takes raw characters and generates proper `keydown`, `keypress`/`input`, and `keyup` events on your page.\n\nFor finer control, you can use [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down), [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up), and [keyboard.insertText(text)](https://playwright.dev/docs/api/class-keyboard#keyboard-insert-text) to manually fire events as if they were generated from a real keyboard.\n\nAn example of holding down `Shift` in order to select and delete some text:\n\n```js await page.keyboard.type('Hello World!'); await page.keyboard.press('ArrowLeft');\n\nawait page.keyboard.down('Shift'); for (let i = 0; i < ' World'.length; i++) await page.keyboard.press('ArrowLeft'); await page.keyboard.up('Shift');\n\nawait page.keyboard.press('Backspace'); // Result text will end up saying 'Hello!' ```\n\nAn example of pressing uppercase `A`\n\n```js await page.keyboard.press('Shift+KeyA'); // or await page.keyboard.press('Shift+A'); ```\n\nAn example to trigger select-all with the keyboard\n\n```js await page.keyboard.press('ControlOrMeta+A'); ```"},mouse:{type:"object",properties:{click:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["x","y"],description:"Shortcut for [mouse.move(x, y[, options])](https://playwright.dev/docs/api/class-mouse#mouse-move), [mouse.down([options])](https://playwright.dev/docs/api/class-mouse#mouse-down), [mouse.up([options])](https://playwright.dev/docs/api/class-mouse#mouse-up)."},dblclick:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["x","y"],description:"Shortcut for [mouse.move(x, y[, options])](https://playwright.dev/docs/api/class-mouse#mouse-move), [mouse.down([options])](https://playwright.dev/docs/api/class-mouse#mouse-down), [mouse.up([options])](https://playwright.dev/docs/api/class-mouse#mouse-up), [mouse.down([options])](https://playwright.dev/docs/api/class-mouse#mouse-down) and [mouse.up([options])](https://playwright.dev/docs/api/class-mouse#mouse-up)."},down:{kind:"function",type:"Promise",parameters:{options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."}},additionalProperties:false}},required:[],description:"Dispatches a `mousedown` event."},move:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."},options:{type:"object",properties:{steps:{type:"number",description:"Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between Playwright's current cursor position and the provided destination. When set to 1, emits a single `mousemove` event at the destination location."}},additionalProperties:false}},required:["x","y"],description:"Dispatches a `mousemove` event."},up:{kind:"function",type:"Promise",parameters:{options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."}},additionalProperties:false}},required:[],description:"Dispatches a `mouseup` event."}},required:["click","dblclick","down","move","up"],additionalProperties:false,description:"The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.\n\n**NOTE** If you want to debug where the mouse moved, you can use the [Trace viewer](https://playwright.dev/docs/trace-viewer-intro) or [Playwright Inspector](https://playwright.dev/docs/running-tests). A red dot showing the location of the mouse will be shown for every mouse action.\n\nEvery `page` object has its own Mouse, accessible with [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse).\n\n```js // Using \u2018page.mouse\u2019 to trace a 100x100 square. await page.mouse.move(0, 0); await page.mouse.down(); await page.mouse.move(0, 100); await page.mouse.move(100, 100); await page.mouse.move(100, 0); await page.mouse.move(0, 0); await page.mouse.up(); ```"},touchscreen:{type:"object",properties:{tap:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."}},required:["x","y"],description:"Dispatches a `touchstart` and `touchend` event with a single touch at the position ([`x`](https://playwright.dev/docs/api/class-touchscreen#touchscreen-tap-option-x),[`y`](https://playwright.dev/docs/api/class-touchscreen#touchscreen-tap-option-y)).\n\n**NOTE** [page.tap(selector[, options])](https://playwright.dev/docs/api/class-page#page-tap) the method will throw if [`hasTouch`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-has-touch) option of the browser context is false."}},required:["tap"],additionalProperties:false,description:"The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.\n\nThis class is limited to emulating tap gestures. For examples of other gestures simulated by manually dispatching touch events, see the [emulating legacy touch events](https://playwright.dev/docs/touch-events) page."},takeScreenshot:{kind:"function",type:"Promise",parameters:{stitchOptions:{type:"object",properties:{blend:{type:"string",enum:["clear","source","over","in","out","atop","dest","dest-over","dest-in","dest-out","dest-atop","xor","add","saturate","multiply","screen","overlay","darken","lighten","colour-dodge","colour-burn","hard-light","soft-light","difference","exclusion"],description:"How to blend this image with the image below. (optional)",default:"multiply"}},additionalProperties:false}},required:[],description:"This method will take a screenshot at the position that it activated, its useful for taking a screenshot in sequence for events/actions. In the end the screenshots will be merged with the final screenshot."},takeScreenshotAll:{kind:"function",type:"Promise",parameters:{stitchOptions:{type:"object",properties:{blend:{type:"string",enum:["clear","source","over","in","out","atop","dest","dest-over","dest-in","dest-out","dest-atop","xor","add","saturate","multiply","screen","overlay","darken","lighten","colour-dodge","colour-burn","hard-light","soft-light","difference","exclusion"],description:"How to blend this image with the image below. (optional)",default:"multiply"}},additionalProperties:false}},required:[],description:"This method will take a screenshot after each action, its useful for looking at over all action execution. In the end the screenshots will be merged."},takeElementScreenshot:{kind:"function",type:"Promise",parameters:{selector:{type:"string"}},required:["selector"],description:"This method will take a screenshot of an element."},takeScreenshotOptions:{kind:"function",type:"Promise",parameters:{mergeType:{type:"string",enum:["stitch","overlay"]},stitchOptions:{type:"object",properties:{direction:{type:"string",enum:["vertical","horizontal"],description:"Direction of the merged image."},align:{type:"string",enum:["start","center","end"],description:"Aligning of given images. If the images are not all the same size, images will be sorted to largest image. Possible values are `start`, `center` and `end`. Default is `start`."},offset:{type:"number",description:"Offset in pixels between each image. Default is `0`"},margin:{type:"string",description:"Set the margin of image, considered as standard css shorthand properties (e.g. '40 40 0 10')",default:"0 0 0 0"},color:{type:"string",description:"Set the background color of image."}},additionalProperties:false},overlayOptions:{type:"object",properties:{blend:{type:"string",enum:["clear","source","over","in","out","atop","dest","dest-over","dest-in","dest-out","dest-atop","xor","add","saturate","multiply","screen","overlay","darken","lighten","colour-dodge","colour-burn","hard-light","soft-light","difference","exclusion"],description:"How to blend this image with the image below. (optional)",default:"multiply"}},additionalProperties:false}},required:[],description:"The purpose of this action is to have centralized options for all screenshots. This action can be used in conjunction with takeScreenshot action only. Only one instance can be used."}};function Se(){let e=ke,t=k().customActionSchema;return t&&(e={...e,...t}),e}async function Pe(e,t){let o=Se();if(!ve(o,t))return;let s=ge(t,o),i=t.name.split("."),r=e,n=[r];for(let a=0;a<i.length;a++){let p=i[a];if(typeof r!="object"&&typeof r!="function"||r===null)break;let c=r[p];if(c===void 0)break;r=c,n.push(r);}if(n.length!==1&&typeof r=="function")return await r.call(n[n.length-2],...s)}async function Te(e){await e.waitForLoadState("load"),await e.evaluate(`
5
+ [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).`},uncheck:{kind:"function",type:"Promise",parameters:{selector:{type:"string",description:"A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used."},options:{type:"object",properties:{force:{type:"boolean",description:"Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`."},noWaitAfter:{type:"boolean",description:"This option has no effect.",deprecated:"This option has no effect."},position:{type:"object",properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:false,description:"A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element."},strict:{type:"boolean",description:"When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception."},timeout:{type:"number",description:"Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout` option in the config, or by using the [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods."},trial:{type:"boolean",description:"When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it."}},additionalProperties:false}},required:["selector"],description:"**NOTE** Use locator-based [locator.uncheck([options])](https://playwright.dev/docs/api/class-locator#locator-uncheck) instead. Read more about [locators](https://playwright.dev/docs/locators).\n\nThis method unchecks an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-uncheck-option-selector) by performing the following steps: 1. Find an element matching [`selector`](https://playwright.dev/docs/api/class-page#page-uncheck-option-selector). If there is none, wait until a matching element is attached to the DOM. 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked, this method returns immediately. 1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless [`force`](https://playwright.dev/docs/api/class-page#page-uncheck-option-force) option is set. If the element is detached during the checks, the whole action is retried. 1. Scroll the element into view if needed. 1. Use [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse) to click in the center of the element. 1. Ensure that the element is now unchecked. If not, this method throws.\n\nWhen all steps combined have not finished during the specified [`timeout`](https://playwright.dev/docs/api/class-page#page-uncheck-option-timeout), this method throws a [TimeoutError](https://playwright.dev/docs/api/class-timeouterror). Passing zero timeout disables this."},waitForTimeout:{kind:"function",type:"Promise",parameters:{timeout:{type:"number",description:"A timeout to wait for"}},required:["timeout"],description:"**NOTE** Never wait for timeout in production. Tests that wait for time are inherently flaky. Use [Locator](https://playwright.dev/docs/api/class-locator) actions and web assertions that wait automatically.\n\nWaits for the given [`timeout`](https://playwright.dev/docs/api/class-page#page-wait-for-timeout-option-timeout) in milliseconds.\n\nNote that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be flaky. Use signals such as network events, selectors becoming visible and others instead.\n\n**Usage**\n\n```js // wait for 1 second await page.waitForTimeout(1000); ```"},keyboard:{type:"object",properties:{down:{kind:"function",type:"Promise",parameters:{key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."}},required:["key"],description:"Dispatches a `keydown` event.\n\n[`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:\n\n`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.\n\nFollowing modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`. `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.\n\nHolding down `Shift` will type the text that corresponds to the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) in the upper case.\n\nIf [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.\n\nIf [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-down-option-key) is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier active. To release the modifier key, use [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up).\n\nAfter the key is pressed once, subsequent calls to [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down) will have [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up).\n\n**NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case."},insertText:{kind:"function",type:"Promise",parameters:{text:{type:"string",description:"Sets input to the specified text value."}},required:["text"],description:"Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.\n\n**Usage**\n\n```js page.keyboard.insertText('\u55E8'); ```\n\n**NOTE** Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case."},press:{kind:"function",type:"Promise",parameters:{key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["key"],description:"**NOTE** In most cases, you should use [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press) instead.\n\n[`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to generate the text for. A superset of the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:\n\n`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.\n\nFollowing modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`. `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.\n\nHolding down `Shift` will type the text that corresponds to the [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) in the upper case.\n\nIf [`key`](https://playwright.dev/docs/api/class-keyboard#keyboard-press-option-key) is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.\n\nShortcuts such as `key: \"Control+o\"`, `key: \"Control++` or `key: \"Control+Shift+T\"` are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.\n\n**Usage**\n\n```js const page = await browser.newPage(); await page.goto('https://keycode.info'); await page.keyboard.press('A'); await page.screenshot({ path: 'A.png' }); await page.keyboard.press('ArrowLeft'); await page.screenshot({ path: 'ArrowLeft.png' }); await page.keyboard.press('Shift+O'); await page.screenshot({ path: 'O.png' }); await browser.close(); ```\n\nShortcut for [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down) and [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up)."},type:{kind:"function",type:"Promise",parameters:{text:{type:"string",description:"A text to type into a focused element."},options:{type:"object",properties:{delay:{type:"number",description:"Time to wait between key presses in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["text"],description:"**NOTE** In most cases, you should use [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).\n\nSends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.\n\nTo press a special key, like `Control` or `ArrowDown`, use [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press).\n\n**Usage**\n\n```js await page.keyboard.type('Hello'); // Types instantly await page.keyboard.type('World', { delay: 100 }); // Types slower, like a user ```\n\n**NOTE** Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.\n\n**NOTE** For characters that are not on a US keyboard, only an `input` event will be sent."},up:{kind:"function",type:"Promise",parameters:{key:{type:"string",description:"Name of the key to press or a character to generate, such as `ArrowLeft` or `a`."}},required:["key"],description:"Dispatches a `keyup` event."}},required:["down","insertText","press","type","up"],additionalProperties:false,description:"Keyboard provides an api for managing a virtual keyboard. The high level api is [keyboard.type(text[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-type), which takes raw characters and generates proper `keydown`, `keypress`/`input`, and `keyup` events on your page.\n\nFor finer control, you can use [keyboard.down(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-down), [keyboard.up(key)](https://playwright.dev/docs/api/class-keyboard#keyboard-up), and [keyboard.insertText(text)](https://playwright.dev/docs/api/class-keyboard#keyboard-insert-text) to manually fire events as if they were generated from a real keyboard.\n\nAn example of holding down `Shift` in order to select and delete some text:\n\n```js await page.keyboard.type('Hello World!'); await page.keyboard.press('ArrowLeft');\n\nawait page.keyboard.down('Shift'); for (let i = 0; i < ' World'.length; i++) await page.keyboard.press('ArrowLeft'); await page.keyboard.up('Shift');\n\nawait page.keyboard.press('Backspace'); // Result text will end up saying 'Hello!' ```\n\nAn example of pressing uppercase `A`\n\n```js await page.keyboard.press('Shift+KeyA'); // or await page.keyboard.press('Shift+A'); ```\n\nAn example to trigger select-all with the keyboard\n\n```js await page.keyboard.press('ControlOrMeta+A'); ```"},mouse:{type:"object",properties:{click:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["x","y"],description:"Shortcut for [mouse.move(x, y[, options])](https://playwright.dev/docs/api/class-mouse#mouse-move), [mouse.down([options])](https://playwright.dev/docs/api/class-mouse#mouse-down), [mouse.up([options])](https://playwright.dev/docs/api/class-mouse#mouse-up)."},dblclick:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."},options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},delay:{type:"number",description:"Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0."}},additionalProperties:false}},required:["x","y"],description:"Shortcut for [mouse.move(x, y[, options])](https://playwright.dev/docs/api/class-mouse#mouse-move), [mouse.down([options])](https://playwright.dev/docs/api/class-mouse#mouse-down), [mouse.up([options])](https://playwright.dev/docs/api/class-mouse#mouse-up), [mouse.down([options])](https://playwright.dev/docs/api/class-mouse#mouse-down) and [mouse.up([options])](https://playwright.dev/docs/api/class-mouse#mouse-up)."},down:{kind:"function",type:"Promise",parameters:{options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."}},additionalProperties:false}},required:[],description:"Dispatches a `mousedown` event."},move:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."},options:{type:"object",properties:{steps:{type:"number",description:"Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between Playwright's current cursor position and the provided destination. When set to 1, emits a single `mousemove` event at the destination location."}},additionalProperties:false}},required:["x","y"],description:"Dispatches a `mousemove` event."},up:{kind:"function",type:"Promise",parameters:{options:{type:"object",properties:{button:{type:"string",enum:["left","right","middle"],description:"Defaults to `left`."},clickCount:{type:"number",description:"defaults to 1. See [UIEvent.detail]."}},additionalProperties:false}},required:[],description:"Dispatches a `mouseup` event."}},required:["click","dblclick","down","move","up"],additionalProperties:false,description:"The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.\n\n**NOTE** If you want to debug where the mouse moved, you can use the [Trace viewer](https://playwright.dev/docs/trace-viewer-intro) or [Playwright Inspector](https://playwright.dev/docs/running-tests). A red dot showing the location of the mouse will be shown for every mouse action.\n\nEvery `page` object has its own Mouse, accessible with [page.mouse](https://playwright.dev/docs/api/class-page#page-mouse).\n\n```js // Using \u2018page.mouse\u2019 to trace a 100x100 square. await page.mouse.move(0, 0); await page.mouse.down(); await page.mouse.move(0, 100); await page.mouse.move(100, 100); await page.mouse.move(100, 0); await page.mouse.move(0, 0); await page.mouse.up(); ```"},touchscreen:{type:"object",properties:{tap:{kind:"function",type:"Promise",parameters:{x:{type:"number",description:"X coordinate relative to the main frame's viewport in CSS pixels."},y:{type:"number",description:"Y coordinate relative to the main frame's viewport in CSS pixels."}},required:["x","y"],description:"Dispatches a `touchstart` and `touchend` event with a single touch at the position ([`x`](https://playwright.dev/docs/api/class-touchscreen#touchscreen-tap-option-x),[`y`](https://playwright.dev/docs/api/class-touchscreen#touchscreen-tap-option-y)).\n\n**NOTE** [page.tap(selector[, options])](https://playwright.dev/docs/api/class-page#page-tap) the method will throw if [`hasTouch`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-has-touch) option of the browser context is false."}},required:["tap"],additionalProperties:false,description:"The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.\n\nThis class is limited to emulating tap gestures. For examples of other gestures simulated by manually dispatching touch events, see the [emulating legacy touch events](https://playwright.dev/docs/touch-events) page."},takeScreenshot:{kind:"function",type:"Promise",parameters:{stitchOptions:{type:"object",properties:{blend:{type:"string",enum:["clear","source","over","in","out","atop","dest","dest-over","dest-in","dest-out","dest-atop","xor","add","saturate","multiply","screen","overlay","darken","lighten","colour-dodge","colour-burn","hard-light","soft-light","difference","exclusion"],description:"How to blend this image with the image below. (optional)",default:"multiply"}},additionalProperties:false}},required:[],description:"This method will take a screenshot at the position that it activated, its useful for taking a screenshot in sequence for events/actions. In the end the screenshots will be merged with the final screenshot."},takeScreenshotAll:{kind:"function",type:"Promise",parameters:{stitchOptions:{type:"object",properties:{blend:{type:"string",enum:["clear","source","over","in","out","atop","dest","dest-over","dest-in","dest-out","dest-atop","xor","add","saturate","multiply","screen","overlay","darken","lighten","colour-dodge","colour-burn","hard-light","soft-light","difference","exclusion"],description:"How to blend this image with the image below. (optional)",default:"multiply"}},additionalProperties:false}},required:[],description:"This method will take a screenshot after each action, its useful for looking at over all action execution. In the end the screenshots will be merged."},takeElementScreenshot:{kind:"function",type:"Promise",parameters:{selector:{type:"string"}},required:["selector"],description:"This method will take a screenshot of an element."},takeScreenshotOptions:{kind:"function",type:"Promise",parameters:{mergeType:{type:"string",enum:["stitch","overlay"]},stitchOptions:{type:"object",properties:{direction:{type:"string",enum:["vertical","horizontal"],description:"Direction of the merged image."},align:{type:"string",enum:["start","center","end"],description:"Aligning of given images. If the images are not all the same size, images will be sorted to largest image. Possible values are `start`, `center` and `end`. Default is `start`."},offset:{type:"number",description:"Offset in pixels between each image. Default is `0`"},margin:{type:"string",description:"Set the margin of image, considered as standard css shorthand properties (e.g. '40 40 0 10')",default:"0 0 0 0"},color:{type:"string",description:"Set the background color of image."}},additionalProperties:false},overlayOptions:{type:"object",properties:{blend:{type:"string",enum:["clear","source","over","in","out","atop","dest","dest-over","dest-in","dest-out","dest-atop","xor","add","saturate","multiply","screen","overlay","darken","lighten","colour-dodge","colour-burn","hard-light","soft-light","difference","exclusion"],description:"How to blend this image with the image below. (optional)",default:"multiply"}},additionalProperties:false}},required:[],description:"The purpose of this action is to have centralized options for all screenshots. This action can be used in conjunction with takeScreenshot action only. Only one instance can be used."}};function Pe(){let e=Se,t=k().customActionSchema;return t&&(e={...e,...t}),e}async function Te(e,t){let o=Pe();if(!xe(o,t))return;let s=ge(t,o),i=t.name.split("."),r=e,n=[r];for(let a=0;a<i.length;a++){let p=i[a];if(typeof r!="object"&&typeof r!="function"||r===null)break;let c=r[p];if(c===void 0)break;r=c,n.push(r);}if(n.length!==1&&typeof r=="function")return await r.call(n[n.length-2],...s)}async function Ie(e){await e.waitForLoadState("load"),await e.evaluate(`
5
6
  (() => {
6
7
  if (window !== window.parent) return;
7
8
  const box = document.createElement('playwright-mouse-pointer');
@@ -128,5 +129,5 @@ to press keys one by one if there is special keyboard handling on the page - in
128
129
  true,
129
130
  );
130
131
  })();
131
- `);}var st=["waitForSelector","waitForTimeout","takeScreenshot","takeScreenshotAll","takeScreenshotOptions"];function H(e){return !st.includes(e.name)}async function Ie(e,t){if(t){let o=["Shift","Meta","Control","Alt"];for(let s=0;s<t.length;s++){let i=t[s];for(let r=0;r<i.actions.length;r++){let n=i.actions[r];n.name==="keyboard.down"&&n.args&&n.args.key&&o.includes(n.args.key)&&await e.keyboard.up(n.args.key);}}}}function De(e,t,o){let s=e[t+1];return o&&e.length>1&&e.length>t+1&&s&&H(s)}async function j(e,t,o,s){let i={...t,requestId:t.requestId||""};return o.beforeScreenshot&&await o.beforeScreenshot(e,i,i),s?s.screenshot(t.screenshotOptions):e.screenshot(t.screenshotOptions)}async function N(e,t){let o={...e,requestId:e.requestId||""},s=k(),{screenshotOptions:i={}}=s,r=e.browserOptions,n=await s.getPage(o.browserType,r,o);if(!n)throw new Error("Make sure to return an instance of a page from getPage.");ee(n);let a=B(e),p=U(e),c=fe(s.storybookEndpoint,e.storyId,e.props,a,p);s.afterUrlConstruction&&(c=s.afterUrlConstruction(c,o)),await n.goto(c,s.pageGotoOptions),s.afterNavigation&&await s.afterNavigation(n,o),r&&r.cursor&&await Te(n);let l=[],u,g;if(e.actionSets){let m=e.actionSets.reduce((d,y)=>(d=[...d,...y.actions],d),[]);g=m.slice(-1)[0];let h=m.find(d=>d.name==="takeScreenshotAll");u=m.find(d=>d.name==="takeScreenshotOptions");let v=m.filter(d=>!["takeScreenshotAll","takeScreenshotOptions"].includes(d.name));h&&v.filter(d=>H(d)).length>0&&l.push({buffer:await j(n,e,s),options:h.args});for(let d=0;d<v.length;d++){let y=v[d];if(y.name==="takeElementScreenshot"){if(y&&y.args&&y.args.selector){let D=await n.$(y.args.selector);l.push({buffer:await j(n,e,s,D||void 0),options:y.args});}continue}if(y.name==="takeScreenshot"){l.push({buffer:await j(n,e,s),options:y.args});continue}await Pe(n,y),De(v,d,!!h)&&l.push({buffer:await j(n,e,s),options:h?.args||{}});}}let b=g&&(g.name==="takeElementScreenshot"||g.name==="takeScreenshot"),f;if(b||(f=await j(n,e,s)),s.releaseModifierKey&&await Ie(n,e.actionSets||[]),s.afterScreenshot&&await s.afterScreenshot(n,o),l.length){let m=e&&e.screenshotOptions&&e.screenshotOptions.type?e.screenshotOptions.type:"png",h=u&&u.args?u.args:{};if(h={mergeType:h.mergeType?h.mergeType:i.mergeType||"stitch",overlayOptions:{...i.overlayOptions,...h.overlayOptions},stitchOptions:{...i.stitchOptions,...h.stitchOptions}},h.mergeType==="stitch"){let v=l.map(d=>d.buffer);f&&v.push(f),f=await(await it__default.default(v,{...h.stitchOptions})).toFormat(m).toBuffer();}else {let v=f||l[0]?.buffer;if(!v)throw new Error("Unable to create screenshot image buffer.");let y=(f===void 0&&l.length===1?l:l.filter((D,We)=>!(f===void 0&&We===0))).map(D=>({blend:"multiply",input:D.buffer,...h.overlayOptions,...D.options?D.options.stitchOptions:{}}));f=await rt__default.default(v).composite(y).toFormat(m).toBuffer();}}if(!f)throw new Error("Unable to create screenshot image buffer.");return {base64:t?f.toString("base64"):void 0,browserName:e.browserType,buffer:f}}function $(e,t){e.browserOptions&&t.browserOptionsId&&(t.browserOptions=e.browserOptions[t.browserOptionsId]),e.screenshotOptions&&t.screenshotOptionsId&&(t.screenshotOptions=e.screenshotOptions[t.screenshotOptionsId]);}async function z(e){return await nt__default.default([e&&e!=="*"?e:"**/*.playwright.json","!node_modules/**"])}async function Oe(e){let{onScreenshotReady:t,playwrightJsonPath:o,requestId:s}=e,i=o&&C__namespace.default.existsSync(o)?[o]:await z(o),r=[];for(let n of i){if(!n)continue;let a=await W(n);for(let p of a.storyData)if(p&&p.data.screenshots&&p.data.screenshots.length)for(let c of p.data.screenshots){if(!c)continue;$(a.playWrightData,c);let l=await N({requestId:s,storyId:p.storyId,...c},false),u=E({browserType:c.browserType,filePath:n,storyId:p.storyId,title:c.title});r.push({buffer:l.buffer,configFile:n,storyId:p.storyId}),t&&await t(l.buffer,u);}}return r}async function Ae(e,t,o){return new Promise((s,i)=>{try{let r=E(e),n=k(),a=n.imageDiffOptions??{},p=P__namespace.default.resolve(process.cwd(),"__stories__",e.storyId,"__diff_output__");C__namespace.existsSync(p)||C__namespace.mkdirSync(p,{recursive:!0});let c=diffSnapshot.runDiffImageToSnapshot({blur:0,diffDir:p,diffDirection:n.diffDirection?n.diffDirection:"horizontal",failureThreshold:0,failureThresholdType:"pixel",receivedImageBuffer:t,snapshotIdentifier:r.screenshotIdentifier,snapshotsDir:r.screenshotsDir,updatePassedSnapshot:!1,updateSnapshot:!1,...a,...o});c.pass||C__namespace.rmdirSync(p,{recursive:!0}),c.added&&c.pass===!1&&delete c.pass,c.diffDirection=n.diffDirection,a.allowSizeMismatch&&(c.diffSize=!1),s(c);}catch(r){i(r);}})}function K(e,t,o=false){if(e){if(!e.stories){if(!o)return;e.stories={};}if(!(!o&&!e.stories[t]))return e.stories[t]||(e.stories[t]={}),e.stories[t]}}function Ee(e,t){if(!e||!e.length)return;return e.map(s=>({...s,actions:s.actions.map(i=>({...i,id:i.id||nanoid.nanoid(12)})),id:s.id||nanoid.nanoid(12)}))}async function qe(e){let t=A(e.filePath),o=await O(t.path,e.storyId);if(!o)return;let s=K(o,e.storyId);if(!s||!s.screenshots)return;let i=s.screenshots.find(r=>r.id===e.screenshotId);return i&&($(o,i),{...i,actionSets:Ee(i.actionSets)})}async function Me(e){let t=e.requestId||"",{requestType:o="story-screenshot"}=e,s=k(),i=await qe(e);if(!i)throw new Error("Unable to find screenshot data.");let r={},n;try{if(n=await N({actionSets:i.actionSets,args:B(i),browserOptions:i.browserOptions,browserType:i.browserType,globals:U(i),props:i.props,requestId:e.requestId,requestType:o,screenshotOptions:i.screenshotOptions,storyId:e.storyId},!0),s.compareScreenshot!==void 0){let a=E({...e,browserType:i.browserType,title:i.title});if(!C__namespace.default.existsSync(a.filePath))throw new Error(`Unable to find the file for '${a.screenshotIdentifier}' screenshot in '${a.screenshotsDir}' directory!`);let p={...a,get base64(){return C__namespace.default.readFileSync(a.filePath,{encoding:"base64"})},get buffer(){return C__namespace.default.readFileSync(a.filePath)}},c=await s.compareScreenshot({...e,requestId:t,...i,baseImage:p,screenshot:n});if(c!==!1){let{diffImageString:l,...u}=c;r={imgSrcString:l,...u,newScreenshot:p.base64};}}Object.keys(r).length===0&&(r=await Ae({browserType:i.browserType,filePath:e.filePath,storyId:e.storyId,title:i.title},n.buffer)),r.added&&r.pass===!1&&delete r.pass,r.newScreenshot=n.base64;}catch(a){r.pass=false,r.error=typeof a=="string"?a:a.message;}return r.screenshotId=e.screenshotId,r.storyId=e.storyId,r.screenshotData=i,r.filePath=e.filePath,r}async function Ce(e){let t=A(e.filePath),o=await O(t.path,e.storyId);e.requestType=e.requestType||"story";let s={...e,requestId:e.requestId||""},i=k(),r=K(o,e.storyId);if(!r||!r.screenshots)throw new Error("Unable to find story screenshots");let n=[];i.beforeStoryImageDiff&&await i.beforeStoryImageDiff(s);for(let a=0;a<r.screenshots.length;a++){let p=r.screenshots[a],c=await Me({filePath:e.filePath,requestId:s.requestId,requestType:e.requestType,screenshotId:p.id,storyId:e.storyId});n.push(c);}return i.afterStoryImageDiff&&await i.afterStoryImageDiff(n,s),n}async function je(e){let{filePath:t,onComplete:o,storyId:s,requestType:i}=e,r=k(),n=await W(t),a=(n.storyData[0]?.storyId??s??"").split("--")[0],p=lt__default.default(r.concurrencyLimit?.story??1);r.beforeFileImageDiff&&await r.beforeFileImageDiff({...e,storyId:a});let c=n.storyData.reduce((g,b)=>(i==="story"&&s&&b.storyId!==s||b.data.screenshots&&b.data.screenshots.length&&g.push(p(async()=>Ce({filePath:t,requestId:e.requestId,requestType:e.requestType?e.requestType:s?"story":"file",storyId:b.storyId}))),g),[]),u=(await Promise.all(c)).reduce((g,b)=>{let f=b.map(m=>{if(m.added&&m.pass===false){let h={...m};return delete h.pass,h}return m});return [...g,...f]},[]);return r.afterFileImageDiff&&await r.afterFileImageDiff(u,{...e,storyId:a}),o&&await o(u),u}async function cr(e,t){let o=await z(e),s=[];for(let i=0;i<o.length;i++){let r=o[i],n=await je({filePath:r,requestId:t&&t.requestId?t.requestId:nanoid.nanoid()});s=[...s,...n];}return t&&t.onComplete&&t.onComplete(s),s}expect.extend({toMatchImageSnapshot:jestImageSnapshot.toMatchImageSnapshot});async function gr(e,t){let{testPath:o}=this,i=P__namespace.default.parse(o).dir,r=e?P__namespace.default.resolve(P__namespace.default.join(i,e)):void 0,n=r?P__namespace.default.relative(process.cwd(),r).replace(/\\/g,"/"):void 0;try{await Oe({onScreenshotReady:(a,p)=>{try{expect(a).toMatchImageSnapshot({...t,customSnapshotIdentifier:p.screenshotIdentifier,customSnapshotsDir:p.screenshotsDir});}catch(c){throw c.message}},playwrightJsonPath:e==="*"?e:n,requestId:nanoid.nanoid()});}catch(a){return {message:()=>a,pass:false}}return {message:()=>"expected page screenshot to match.",pass:true}}exports.getScreenshots=Oe;exports.runImageDiff=cr;exports.toMatchScreenshots=gr;//# sourceMappingURL=index.js.map
132
+ `);}var at=["waitForSelector","waitForTimeout","takeScreenshot","takeScreenshotAll","takeScreenshotOptions"];function H(e){return !at.includes(e.name)}async function De(e,t){if(t){let o=["Shift","Meta","Control","Alt"];for(let s=0;s<t.length;s++){let i=t[s];for(let r=0;r<i.actions.length;r++){let n=i.actions[r];n.name==="keyboard.down"&&n.args&&n.args.key&&o.includes(n.args.key)&&await e.keyboard.up(n.args.key);}}}}function Oe(e,t,o){let s=e[t+1];return o&&e.length>1&&e.length>t+1&&s&&H(s)}async function j(e,t,o,s){let i={...t,requestId:t.requestId||""};return o.beforeScreenshot&&await o.beforeScreenshot(e,i,i),s?s.screenshot(t.screenshotOptions):e.screenshot(t.screenshotOptions)}async function $(e,t){let o={...e,requestId:e.requestId||""},s=k(),{screenshotOptions:i={}}=s,r=e.browserOptions,n=await s.getPage(o.browserType,r,o);if(!n)throw new Error("Make sure to return an instance of a page from getPage.");te(n);let a=_(e),p=B(e),c=ye(s.storybookEndpoint,e.storyId,e.props,a,p);s.afterUrlConstruction&&(c=s.afterUrlConstruction(c,o)),await n.goto(c,s.pageGotoOptions),s.afterNavigation&&await s.afterNavigation(n,o),r&&r.cursor&&await Ie(n);let l=[],m,y;if(e.actionSets){let u=e.actionSets.reduce((d,g)=>(d=[...d,...g.actions],d),[]);y=u.slice(-1)[0];let h=u.find(d=>d.name==="takeScreenshotAll");m=u.find(d=>d.name==="takeScreenshotOptions");let v=u.filter(d=>!["takeScreenshotAll","takeScreenshotOptions"].includes(d.name));h&&v.filter(d=>H(d)).length>0&&l.push({buffer:await j(n,e,s),options:h.args});for(let d=0;d<v.length;d++){let g=v[d];if(g.name==="takeElementScreenshot"){if(g&&g.args&&g.args.selector){let D=await n.$(g.args.selector);l.push({buffer:await j(n,e,s,D||void 0),options:g.args});}continue}if(g.name==="takeScreenshot"){l.push({buffer:await j(n,e,s),options:g.args});continue}await Te(n,g),Oe(v,d,!!h)&&l.push({buffer:await j(n,e,s),options:h?.args||{}});}}let w=y&&(y.name==="takeElementScreenshot"||y.name==="takeScreenshot"),f;if(w||(f=await j(n,e,s)),s.releaseModifierKey&&await De(n,e.actionSets||[]),s.afterScreenshot&&await s.afterScreenshot(n,o),l.length){let u=e&&e.screenshotOptions&&e.screenshotOptions.type?e.screenshotOptions.type:"png",h=m&&m.args?m.args:{};if(h={mergeType:h.mergeType?h.mergeType:i.mergeType||"stitch",overlayOptions:{...i.overlayOptions,...h.overlayOptions},stitchOptions:{...i.stitchOptions,...h.stitchOptions}},h.mergeType==="stitch"){let v=l.map(d=>d.buffer);f&&v.push(f),f=await(await pt__default.default(v,{...h.stitchOptions})).toFormat(u).toBuffer();}else {let v=f||l[0]?.buffer;if(!v)throw new Error("Unable to create screenshot image buffer.");let g=(f===void 0&&l.length===1?l:l.filter((D,Re)=>!(f===void 0&&Re===0))).map(D=>({blend:"multiply",input:D.buffer,...h.overlayOptions,...D.options?D.options.stitchOptions:{}}));f=await ct__default.default(v).composite(g).toFormat(u).toBuffer();}}if(!f)throw new Error("Unable to create screenshot image buffer.");return {base64:t?f.toString("base64"):void 0,browserName:e.browserType,buffer:f}}function z(e,t){e.browserOptions&&t.browserOptionsId&&(t.browserOptions=e.browserOptions[t.browserOptionsId]),e.screenshotOptions&&t.screenshotOptionsId&&(t.screenshotOptions=e.screenshotOptions[t.screenshotOptionsId]);}async function Y(e){return await lt__default.default([e&&e!=="*"?e:"**/*.playwright.json","!node_modules/**"])}async function Ae(e){let{onScreenshotReady:t,playwrightJsonPath:o,requestId:s}=e,i=o&&M__namespace.default.existsSync(o)?[o]:await Y(o),r=[];for(let n of i){if(!n)continue;let a=await R(n);for(let p of a.storyData)if(p&&p.data.screenshots&&p.data.screenshots.length)for(let c of p.data.screenshots){if(!c)continue;z(a.playWrightData,c);let l=await $({requestId:s,storyId:p.storyId,...c},false),m=E({browserType:c.browserType,filePath:n,storyId:p.storyId,title:c.title});r.push({buffer:l.buffer,configFile:n,storyId:p.storyId}),t&&await t(l.buffer,m);}}return r}async function Ee(e,t,o){return new Promise((s,i)=>{try{let r=E(e),n=k(),a=n.imageDiffOptions??{},p=P__namespace.default.resolve(process.cwd(),"__stories__",e.storyId,"__diff_output__");M__namespace.existsSync(p)||M__namespace.mkdirSync(p,{recursive:!0});let c=diffSnapshot.runDiffImageToSnapshot({blur:0,diffDir:p,diffDirection:n.diffDirection?n.diffDirection:"horizontal",failureThreshold:0,failureThresholdType:"pixel",receivedImageBuffer:t,snapshotIdentifier:r.screenshotIdentifier,snapshotsDir:r.screenshotsDir,updatePassedSnapshot:!1,updateSnapshot:!1,...a,...o});c.pass||M__namespace.rmdirSync(p,{recursive:!0}),c.added&&c.pass===!1&&delete c.pass,c.diffDirection=n.diffDirection,a.allowSizeMismatch&&(c.diffSize=!1),s(c);}catch(r){i(r);}})}function K(e,t,o=false){if(e){if(!e.stories){if(!o)return;e.stories={};}if(!(!o&&!e.stories[t]))return e.stories[t]||(e.stories[t]={}),e.stories[t]}}function qe(e,t){if(!e||!e.length)return;return e.map(s=>({...s,actions:s.actions.map(i=>({...i,id:i.id||nanoid.nanoid(12)})),id:s.id||nanoid.nanoid(12)}))}async function Ce(e){let t=A(e.filePath),o=await O(t.path,e.storyId);if(!o)return;let s=K(o,e.storyId);if(!s||!s.screenshots)return;let i=s.screenshots.find(r=>r.id===e.screenshotId);return i&&(z(o,i),{...i,actionSets:qe(i.actionSets)})}async function Me(e){let t=e.requestId||"",{requestType:o="story-screenshot"}=e,s=k(),i=await Ce(e);if(!i)throw new Error("Unable to find screenshot data.");let r={},n;try{if(n=await $({actionSets:i.actionSets,args:_(i),browserOptions:i.browserOptions,browserType:i.browserType,globals:B(i),props:i.props,requestId:e.requestId,requestType:o,screenshotOptions:i.screenshotOptions,storyId:e.storyId},!0),s.compareScreenshot!==void 0){let a=E({...e,browserType:i.browserType,title:i.title});if(!M__namespace.default.existsSync(a.filePath))throw new Error(`Unable to find the file for '${a.screenshotIdentifier}' screenshot in '${a.screenshotsDir}' directory!`);let p={...a,get base64(){return M__namespace.default.readFileSync(a.filePath,{encoding:"base64"})},get buffer(){return M__namespace.default.readFileSync(a.filePath)}},c=await s.compareScreenshot({...e,requestId:t,...i,baseImage:p,screenshot:n});if(c!==!1){let{diffImageString:l,...m}=c;r={imgSrcString:l,...m,newScreenshot:p.base64};}}Object.keys(r).length===0&&(r=await Ee({browserType:i.browserType,filePath:e.filePath,storyId:e.storyId,title:i.title},n.buffer)),r.added&&r.pass===!1&&delete r.pass,r.newScreenshot=n.base64;}catch(a){r.pass=false,r.error=typeof a=="string"?a:a.message;}return r.screenshotId=e.screenshotId,r.storyId=e.storyId,r.screenshotData=i,r.filePath=e.filePath,r}async function je(e){let t=A(e.filePath),o=await O(t.path,e.storyId);e.requestType=e.requestType||"story";let s={...e,requestId:e.requestId||""},i=k(),r=K(o,e.storyId);if(!r||!r.screenshots)throw new Error("Unable to find story screenshots");let n=[];i.beforeStoryImageDiff&&await i.beforeStoryImageDiff(s);for(let a=0;a<r.screenshots.length;a++){let p=r.screenshots[a],c=await Me({filePath:e.filePath,requestId:s.requestId,requestType:e.requestType,screenshotId:p.id,storyId:e.storyId});n.push(c);}return i.afterStoryImageDiff&&await i.afterStoryImageDiff(n,s),n}async function Le(e){let{filePath:t,onComplete:o,storyId:s,requestType:i}=e,r=k(),n=await R(t),a=(n.storyData[0]?.storyId??s??"").split("--")[0],p=mt__default.default(r.concurrencyLimit?.story??1);r.beforeFileImageDiff&&await r.beforeFileImageDiff({...e,storyId:a});let c=n.storyData.reduce((y,w)=>(i==="story"&&s&&w.storyId!==s||w.data.screenshots&&w.data.screenshots.length&&y.push(p(async()=>je({filePath:t,requestId:e.requestId,requestType:e.requestType?e.requestType:s?"story":"file",storyId:w.storyId}))),y),[]),m=(await Promise.all(c)).reduce((y,w)=>{let f=w.map(u=>{if(u.added&&u.pass===false){let h={...u};return delete h.pass,h}return u});return [...y,...f]},[]);return r.afterFileImageDiff&&await r.afterFileImageDiff(m,{...e,storyId:a}),o&&await o(m),m}async function gr(e,t){let o=await Y(e),s=[];for(let i=0;i<o.length;i++){let r=o[i],n=await Le({filePath:r,requestId:t&&t.requestId?t.requestId:nanoid.nanoid()});s=[...s,...n];}return t&&t.onComplete&&t.onComplete(s),s}expect.extend({toMatchImageSnapshot:jestImageSnapshot.toMatchImageSnapshot});async function Pr(e,t){let{testPath:o}=this,i=P__namespace.default.parse(o).dir,r=e?P__namespace.default.resolve(P__namespace.default.join(i,e)):void 0,n=r?P__namespace.default.relative(process.cwd(),r).replace(/\\/g,"/"):void 0;try{await Ae({onScreenshotReady:(a,p)=>{try{expect(a).toMatchImageSnapshot({...t,customSnapshotIdentifier:p.screenshotIdentifier,customSnapshotsDir:p.screenshotsDir});}catch(c){throw c.message}},playwrightJsonPath:e==="*"?e:n,requestId:nanoid.nanoid()});}catch(a){return {message:()=>a,pass:false}}return {message:()=>"expected page screenshot to match.",pass:true}}exports.createScreenshotTitlePrompt=bt;exports.getScreenshots=Ae;exports.runImageDiff=gr;exports.toMatchScreenshots=Pr;//# sourceMappingURL=index.js.map
132
133
  //# sourceMappingURL=index.js.map