@bctrl/sdk 1.0.1 → 1.0.2

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.
Files changed (279) hide show
  1. package/README.md +24 -29
  2. package/dist/bctrl.d.ts +22 -36
  3. package/dist/bctrl.js +40 -75
  4. package/dist/browsers.d.ts +24 -0
  5. package/dist/browsers.js +82 -0
  6. package/dist/errors.d.ts +49 -43
  7. package/dist/errors.js +83 -120
  8. package/dist/files.d.ts +31 -0
  9. package/dist/files.js +97 -0
  10. package/dist/http.d.ts +18 -0
  11. package/dist/http.js +135 -0
  12. package/dist/index.d.ts +9 -12
  13. package/dist/index.js +8 -23
  14. package/dist/invocations.d.ts +24 -0
  15. package/dist/invocations.js +66 -0
  16. package/dist/pagination.d.ts +2 -0
  17. package/dist/pagination.js +13 -0
  18. package/dist/runs.d.ts +38 -0
  19. package/dist/runs.js +99 -0
  20. package/dist/runtimes.d.ts +73 -0
  21. package/dist/runtimes.js +205 -0
  22. package/dist/spaces.d.ts +41 -0
  23. package/dist/spaces.js +96 -0
  24. package/dist/types.d.ts +386 -0
  25. package/dist/types.js +1 -0
  26. package/dist/utils.d.ts +4 -0
  27. package/dist/utils.js +27 -0
  28. package/dist/version.js +2 -2
  29. package/package.json +12 -31
  30. package/dist/agents/browser-use/index.d.ts +0 -1
  31. package/dist/agents/browser-use/index.js +0 -9
  32. package/dist/agents/browser-use/namespace.d.ts +0 -39
  33. package/dist/agents/browser-use/namespace.js +0 -93
  34. package/dist/agents/index.d.ts +0 -2
  35. package/dist/agents/index.js +0 -17
  36. package/dist/agents/stagehand/core.d.ts +0 -93
  37. package/dist/agents/stagehand/core.js +0 -144
  38. package/dist/agents/stagehand/index.d.ts +0 -3
  39. package/dist/agents/stagehand/index.js +0 -24
  40. package/dist/agents/stagehand/namespace.d.ts +0 -51
  41. package/dist/agents/stagehand/namespace.js +0 -65
  42. package/dist/ai-credentials/client.d.ts +0 -12
  43. package/dist/ai-credentials/client.js +0 -70
  44. package/dist/ai-credentials/index.d.ts +0 -1
  45. package/dist/ai-credentials/index.js +0 -1
  46. package/dist/base/event-binding.d.ts +0 -7
  47. package/dist/base/event-binding.js +0 -23
  48. package/dist/base/types.d.ts +0 -109
  49. package/dist/base/types.js +0 -4
  50. package/dist/browser-extensions/client.d.ts +0 -15
  51. package/dist/browser-extensions/client.js +0 -72
  52. package/dist/browser-extensions/index.d.ts +0 -2
  53. package/dist/browser-extensions/index.js +0 -1
  54. package/dist/browser-profiles/client.d.ts +0 -11
  55. package/dist/browser-profiles/client.js +0 -63
  56. package/dist/browser-profiles/index.d.ts +0 -1
  57. package/dist/browser-profiles/index.js +0 -1
  58. package/dist/captcha/index.d.ts +0 -1
  59. package/dist/captcha/index.js +0 -1
  60. package/dist/captcha/namespace.d.ts +0 -34
  61. package/dist/captcha/namespace.js +0 -41
  62. package/dist/client/index.d.ts +0 -1
  63. package/dist/client/index.js +0 -1
  64. package/dist/client/rpc.d.ts +0 -83
  65. package/dist/client/rpc.js +0 -354
  66. package/dist/config.d.ts +0 -5
  67. package/dist/config.js +0 -28
  68. package/dist/constants/browser.d.ts +0 -2
  69. package/dist/constants/browser.js +0 -1
  70. package/dist/contracts/agent-tools.d.ts +0 -45
  71. package/dist/contracts/agent-tools.js +0 -31
  72. package/dist/contracts/automation.d.ts +0 -265
  73. package/dist/contracts/automation.js +0 -109
  74. package/dist/contracts/browser-management.d.ts +0 -179
  75. package/dist/contracts/browser-management.js +0 -95
  76. package/dist/contracts/browser-use.d.ts +0 -136
  77. package/dist/contracts/browser-use.js +0 -93
  78. package/dist/contracts/captcha.d.ts +0 -114
  79. package/dist/contracts/captcha.js +0 -40
  80. package/dist/contracts/desktop.d.ts +0 -223
  81. package/dist/contracts/desktop.js +0 -121
  82. package/dist/contracts/drivers/playwright.d.ts +0 -2008
  83. package/dist/contracts/drivers/playwright.js +0 -2033
  84. package/dist/contracts/drivers/puppeteer.d.ts +0 -1221
  85. package/dist/contracts/drivers/puppeteer.js +0 -941
  86. package/dist/contracts/drivers/selenium.d.ts +0 -156
  87. package/dist/contracts/drivers/selenium.js +0 -61
  88. package/dist/contracts/drivers/stagehand.d.ts +0 -155
  89. package/dist/contracts/drivers/stagehand.js +0 -7
  90. package/dist/contracts/extensions.d.ts +0 -13
  91. package/dist/contracts/extensions.js +0 -9
  92. package/dist/contracts/index.d.ts +0 -13
  93. package/dist/contracts/index.js +0 -13
  94. package/dist/contracts/public-api.d.ts +0 -360
  95. package/dist/contracts/public-api.js +0 -17
  96. package/dist/contracts/runtime.d.ts +0 -81
  97. package/dist/contracts/runtime.js +0 -16
  98. package/dist/contracts/stagehand.d.ts +0 -253
  99. package/dist/contracts/stagehand.js +0 -145
  100. package/dist/contracts/storage.d.ts +0 -51
  101. package/dist/contracts/storage.js +0 -56
  102. package/dist/contracts/vault.d.ts +0 -119
  103. package/dist/contracts/vault.js +0 -112
  104. package/dist/contracts/version.d.ts +0 -3
  105. package/dist/contracts/version.js +0 -16
  106. package/dist/desktop.d.ts +0 -2
  107. package/dist/desktop.js +0 -3
  108. package/dist/drivers/desktop/index.d.ts +0 -65
  109. package/dist/drivers/desktop/index.js +0 -68
  110. package/dist/drivers/desktop/session.d.ts +0 -313
  111. package/dist/drivers/desktop/session.js +0 -432
  112. package/dist/drivers/playwright/event-emitter.d.ts +0 -160
  113. package/dist/drivers/playwright/event-emitter.js +0 -297
  114. package/dist/drivers/playwright/generated/api-request-context.d.ts +0 -137
  115. package/dist/drivers/playwright/generated/api-request-context.js +0 -154
  116. package/dist/drivers/playwright/generated/api-response.d.ts +0 -119
  117. package/dist/drivers/playwright/generated/api-response.js +0 -123
  118. package/dist/drivers/playwright/generated/browser-context.d.ts +0 -284
  119. package/dist/drivers/playwright/generated/browser-context.js +0 -458
  120. package/dist/drivers/playwright/generated/browser.d.ts +0 -120
  121. package/dist/drivers/playwright/generated/browser.js +0 -151
  122. package/dist/drivers/playwright/generated/clock.d.ts +0 -80
  123. package/dist/drivers/playwright/generated/clock.js +0 -94
  124. package/dist/drivers/playwright/generated/console-message.d.ts +0 -94
  125. package/dist/drivers/playwright/generated/console-message.js +0 -89
  126. package/dist/drivers/playwright/generated/coverage.d.ts +0 -57
  127. package/dist/drivers/playwright/generated/coverage.js +0 -66
  128. package/dist/drivers/playwright/generated/dialog.d.ts +0 -79
  129. package/dist/drivers/playwright/generated/dialog.js +0 -80
  130. package/dist/drivers/playwright/generated/element-handle.d.ts +0 -399
  131. package/dist/drivers/playwright/generated/element-handle.js +0 -501
  132. package/dist/drivers/playwright/generated/frame-locator.d.ts +0 -34
  133. package/dist/drivers/playwright/generated/frame-locator.js +0 -63
  134. package/dist/drivers/playwright/generated/frame.d.ts +0 -557
  135. package/dist/drivers/playwright/generated/frame.js +0 -634
  136. package/dist/drivers/playwright/generated/js-handle.d.ts +0 -72
  137. package/dist/drivers/playwright/generated/js-handle.js +0 -92
  138. package/dist/drivers/playwright/generated/keyboard.d.ts +0 -103
  139. package/dist/drivers/playwright/generated/keyboard.js +0 -113
  140. package/dist/drivers/playwright/generated/locator.d.ts +0 -795
  141. package/dist/drivers/playwright/generated/locator.js +0 -974
  142. package/dist/drivers/playwright/generated/mouse.d.ts +0 -97
  143. package/dist/drivers/playwright/generated/mouse.js +0 -109
  144. package/dist/drivers/playwright/generated/page.d.ts +0 -762
  145. package/dist/drivers/playwright/generated/page.js +0 -988
  146. package/dist/drivers/playwright/generated/touchscreen.d.ts +0 -34
  147. package/dist/drivers/playwright/generated/touchscreen.js +0 -37
  148. package/dist/drivers/playwright/generated/tracing.d.ts +0 -78
  149. package/dist/drivers/playwright/generated/tracing.js +0 -80
  150. package/dist/drivers/playwright/generated/worker.d.ts +0 -53
  151. package/dist/drivers/playwright/generated/worker.js +0 -59
  152. package/dist/drivers/playwright/index.d.ts +0 -19
  153. package/dist/drivers/playwright/index.js +0 -20
  154. package/dist/drivers/playwright/remote-base.d.ts +0 -62
  155. package/dist/drivers/playwright/remote-base.js +0 -86
  156. package/dist/drivers/playwright/types.d.ts +0 -148
  157. package/dist/drivers/playwright/types.js +0 -8
  158. package/dist/drivers/puppeteer/errors.d.ts +0 -50
  159. package/dist/drivers/puppeteer/errors.js +0 -71
  160. package/dist/drivers/puppeteer/event-emitter.d.ts +0 -145
  161. package/dist/drivers/puppeteer/event-emitter.js +0 -259
  162. package/dist/drivers/puppeteer/generated/accessibility.d.ts +0 -77
  163. package/dist/drivers/puppeteer/generated/accessibility.js +0 -74
  164. package/dist/drivers/puppeteer/generated/browser-context.d.ts +0 -116
  165. package/dist/drivers/puppeteer/generated/browser-context.js +0 -168
  166. package/dist/drivers/puppeteer/generated/browser.d.ts +0 -169
  167. package/dist/drivers/puppeteer/generated/browser.js +0 -246
  168. package/dist/drivers/puppeteer/generated/console-message.d.ts +0 -54
  169. package/dist/drivers/puppeteer/generated/console-message.js +0 -69
  170. package/dist/drivers/puppeteer/generated/coverage.d.ts +0 -49
  171. package/dist/drivers/puppeteer/generated/coverage.js +0 -57
  172. package/dist/drivers/puppeteer/generated/dialog.d.ts +0 -46
  173. package/dist/drivers/puppeteer/generated/dialog.js +0 -60
  174. package/dist/drivers/puppeteer/generated/element-handle.d.ts +0 -261
  175. package/dist/drivers/puppeteer/generated/element-handle.js +0 -341
  176. package/dist/drivers/puppeteer/generated/file-chooser.d.ts +0 -34
  177. package/dist/drivers/puppeteer/generated/file-chooser.js +0 -43
  178. package/dist/drivers/puppeteer/generated/frame.d.ts +0 -221
  179. package/dist/drivers/puppeteer/generated/frame.js +0 -302
  180. package/dist/drivers/puppeteer/generated/http-request.d.ts +0 -195
  181. package/dist/drivers/puppeteer/generated/http-request.js +0 -243
  182. package/dist/drivers/puppeteer/generated/http-response.d.ts +0 -142
  183. package/dist/drivers/puppeteer/generated/http-response.js +0 -169
  184. package/dist/drivers/puppeteer/generated/js-handle.d.ts +0 -104
  185. package/dist/drivers/puppeteer/generated/js-handle.js +0 -125
  186. package/dist/drivers/puppeteer/generated/keyboard.d.ts +0 -79
  187. package/dist/drivers/puppeteer/generated/keyboard.js +0 -89
  188. package/dist/drivers/puppeteer/generated/locator.d.ts +0 -141
  189. package/dist/drivers/puppeteer/generated/locator.js +0 -164
  190. package/dist/drivers/puppeteer/generated/mouse.d.ts +0 -74
  191. package/dist/drivers/puppeteer/generated/mouse.js +0 -94
  192. package/dist/drivers/puppeteer/generated/page.d.ts +0 -604
  193. package/dist/drivers/puppeteer/generated/page.js +0 -776
  194. package/dist/drivers/puppeteer/generated/target.d.ts +0 -105
  195. package/dist/drivers/puppeteer/generated/target.js +0 -123
  196. package/dist/drivers/puppeteer/generated/touchscreen.d.ts +0 -87
  197. package/dist/drivers/puppeteer/generated/touchscreen.js +0 -103
  198. package/dist/drivers/puppeteer/generated/tracing.d.ts +0 -38
  199. package/dist/drivers/puppeteer/generated/tracing.js +0 -43
  200. package/dist/drivers/puppeteer/generated/web-worker.d.ts +0 -63
  201. package/dist/drivers/puppeteer/generated/web-worker.js +0 -73
  202. package/dist/drivers/puppeteer/index.d.ts +0 -21
  203. package/dist/drivers/puppeteer/index.js +0 -23
  204. package/dist/drivers/puppeteer/remote-base.d.ts +0 -57
  205. package/dist/drivers/puppeteer/remote-base.js +0 -79
  206. package/dist/drivers/puppeteer/types.d.ts +0 -178
  207. package/dist/drivers/puppeteer/types.js +0 -8
  208. package/dist/drivers/selenium/driver.d.ts +0 -28
  209. package/dist/drivers/selenium/driver.js +0 -169
  210. package/dist/drivers/selenium/element.d.ts +0 -34
  211. package/dist/drivers/selenium/element.js +0 -73
  212. package/dist/drivers/selenium/index.d.ts +0 -3
  213. package/dist/drivers/selenium/index.js +0 -5
  214. package/dist/drivers/selenium/types.d.ts +0 -2
  215. package/dist/drivers/selenium/types.js +0 -12
  216. package/dist/drivers/stagehand/generated/context.d.ts +0 -127
  217. package/dist/drivers/stagehand/generated/context.js +0 -153
  218. package/dist/drivers/stagehand/generated/locator.d.ts +0 -324
  219. package/dist/drivers/stagehand/generated/locator.js +0 -368
  220. package/dist/drivers/stagehand/generated/page.d.ts +0 -377
  221. package/dist/drivers/stagehand/generated/page.js +0 -439
  222. package/dist/drivers/stagehand/generated/response.d.ts +0 -197
  223. package/dist/drivers/stagehand/generated/response.js +0 -232
  224. package/dist/drivers/stagehand/index.d.ts +0 -5
  225. package/dist/drivers/stagehand/index.js +0 -8
  226. package/dist/drivers/stagehand/types.d.ts +0 -1
  227. package/dist/drivers/stagehand/types.js +0 -7
  228. package/dist/extensions/client.d.ts +0 -47
  229. package/dist/extensions/client.js +0 -154
  230. package/dist/extensions/index.d.ts +0 -1
  231. package/dist/extensions/index.js +0 -1
  232. package/dist/internal/dev-client.d.ts +0 -5
  233. package/dist/internal/dev-client.js +0 -9
  234. package/dist/internal/rpc-targets.d.ts +0 -17
  235. package/dist/internal/rpc-targets.js +0 -58
  236. package/dist/internal/serialization.d.ts +0 -32
  237. package/dist/internal/serialization.js +0 -42
  238. package/dist/internal/transport.d.ts +0 -24
  239. package/dist/internal/transport.js +0 -29
  240. package/dist/playwright.d.ts +0 -1
  241. package/dist/playwright.js +0 -2
  242. package/dist/puppeteer.d.ts +0 -1
  243. package/dist/puppeteer.js +0 -2
  244. package/dist/selenium.d.ts +0 -1
  245. package/dist/selenium.js +0 -2
  246. package/dist/stagehand.d.ts +0 -1
  247. package/dist/stagehand.js +0 -2
  248. package/dist/storage/client.d.ts +0 -151
  249. package/dist/storage/client.js +0 -329
  250. package/dist/storage/index.d.ts +0 -2
  251. package/dist/storage/index.js +0 -4
  252. package/dist/telemetry.d.ts +0 -18
  253. package/dist/telemetry.js +0 -93
  254. package/dist/updates/client.d.ts +0 -8
  255. package/dist/updates/client.js +0 -128
  256. package/dist/updates/index.d.ts +0 -1
  257. package/dist/updates/index.js +0 -1
  258. package/dist/utils/http.d.ts +0 -39
  259. package/dist/utils/http.js +0 -88
  260. package/dist/utils/index.d.ts +0 -4
  261. package/dist/utils/index.js +0 -4
  262. package/dist/utils/logger.d.ts +0 -27
  263. package/dist/utils/logger.js +0 -74
  264. package/dist/utils/schema.d.ts +0 -17
  265. package/dist/utils/schema.js +0 -31
  266. package/dist/utils/url.d.ts +0 -5
  267. package/dist/utils/url.js +0 -7
  268. package/dist/vault/client.d.ts +0 -43
  269. package/dist/vault/client.js +0 -123
  270. package/dist/vault/index.d.ts +0 -1
  271. package/dist/vault/index.js +0 -1
  272. package/dist/workspaces/browser-runtime.d.ts +0 -251
  273. package/dist/workspaces/browser-runtime.js +0 -1025
  274. package/dist/workspaces/client.d.ts +0 -48
  275. package/dist/workspaces/client.js +0 -222
  276. package/dist/workspaces/index.d.ts +0 -2
  277. package/dist/workspaces/index.js +0 -2
  278. package/dist/workspaces/runtime-event-pump.d.ts +0 -65
  279. package/dist/workspaces/runtime-event-pump.js +0 -716
@@ -1,2033 +0,0 @@
1
- /**
2
- * AUTO-GENERATED FILE - DO NOT EDIT
3
- *
4
- * Generated from: packages/automation-spec/src/drivers/playwright/options.ts
5
- * Run `pnpm generate:sdk-contracts` to regenerate.
6
- */
7
- /**
8
- * Playwright-specific option schemas
9
- *
10
- * These match the real Playwright API 1:1.
11
- * @see https://playwright.dev/docs/api/class-page
12
- * @see https://playwright.dev/docs/api/class-locator
13
- * @see https://playwright.dev/docs/api/class-frame
14
- */
15
- import { z } from 'zod';
16
- // ============================================================================
17
- // Playwright Wait Until Values
18
- // ============================================================================
19
- /**
20
- * WaitUntil values for navigation methods
21
- * @see https://playwright.dev/docs/api/class-page#page-goto
22
- */
23
- export const PlaywrightWaitUntilSchema = z.enum([
24
- 'load', // Wait for the load event
25
- 'domcontentloaded', // Wait for DOMContentLoaded event
26
- 'networkidle', // Wait until there are no network connections for at least 500ms
27
- 'commit', // Wait for network response received and document started loading
28
- ]);
29
- // ============================================================================
30
- // WaitForSelector State Values
31
- // ============================================================================
32
- /**
33
- * State values for waitForSelector
34
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-selector
35
- */
36
- export const PlaywrightWaitForSelectorStateSchema = z.enum([
37
- 'attached', // Wait for element to be present in DOM
38
- 'detached', // Wait for element to not be present in DOM
39
- 'visible', // Wait for element to have non-empty bounding box and no visibility:hidden
40
- 'hidden', // Wait for element to be either detached, have empty bounding box, or visibility:hidden
41
- ]);
42
- // ============================================================================
43
- // Mouse Button
44
- // ============================================================================
45
- /**
46
- * Mouse button options
47
- * @see https://playwright.dev/docs/api/class-mouse#mouse-click
48
- */
49
- export const PlaywrightMouseButtonSchema = z.enum(['left', 'right', 'middle']);
50
- // ============================================================================
51
- // Keyboard Modifiers
52
- // ============================================================================
53
- /**
54
- * Keyboard modifier keys
55
- * @see https://playwright.dev/docs/api/class-locator#locator-click
56
- */
57
- export const PlaywrightKeyboardModifierSchema = z.enum([
58
- 'Alt',
59
- 'Control',
60
- 'ControlOrMeta', // Resolves to Control on Windows/Linux and Meta on macOS
61
- 'Meta',
62
- 'Shift',
63
- ]);
64
- export const PlaywrightModifiersSchema = z.array(PlaywrightKeyboardModifierSchema);
65
- // ============================================================================
66
- // Position (x, y coordinates)
67
- // ============================================================================
68
- /**
69
- * Position relative to element's padding box
70
- * @see https://playwright.dev/docs/api/class-locator#locator-click
71
- */
72
- export const PlaywrightPositionSchema = z.object({
73
- x: z.number(),
74
- y: z.number(),
75
- });
76
- // ============================================================================
77
- // Viewport Configuration
78
- // ============================================================================
79
- /**
80
- * Viewport dimensions for page.setViewportSize()
81
- * @see https://playwright.dev/docs/api/class-page#page-set-viewport-size
82
- */
83
- export const PlaywrightViewportSchema = z.object({
84
- /** Page width in pixels */
85
- width: z.number().int().positive(),
86
- /** Page height in pixels */
87
- height: z.number().int().positive(),
88
- });
89
- /**
90
- * Extended viewport options for browser context
91
- * @see https://playwright.dev/docs/api/class-browser#browser-new-context
92
- */
93
- export const PlaywrightViewportOptionsSchema = z.object({
94
- /** Page width in pixels */
95
- width: z.number().int().positive(),
96
- /** Page height in pixels */
97
- height: z.number().int().positive(),
98
- /** Device scale factor (DPR). Defaults to 1. */
99
- deviceScaleFactor: z.number().positive().optional(),
100
- /** Whether the meta viewport tag is taken into account. Defaults to false. */
101
- isMobile: z.boolean().optional(),
102
- /** Specifies if viewport supports touch events. Defaults to false. */
103
- hasTouch: z.boolean().optional(),
104
- });
105
- // ============================================================================
106
- // Click Options
107
- // ============================================================================
108
- /**
109
- * Options for click() method
110
- * @see https://playwright.dev/docs/api/class-locator#locator-click
111
- * @see https://playwright.dev/docs/api/class-page#page-click
112
- */
113
- export const PlaywrightClickOptionsSchema = z.object({
114
- /** Mouse button to use. Defaults to 'left'. */
115
- button: PlaywrightMouseButtonSchema.optional(),
116
- /** Number of clicks. Defaults to 1. */
117
- clickCount: z.number().int().positive().optional(),
118
- /** Time to wait between mousedown and mouseup in milliseconds. Defaults to 0. */
119
- delay: z.number().nonnegative().optional(),
120
- /** Whether to bypass actionability checks. Defaults to false. */
121
- force: z.boolean().optional(),
122
- /** Modifier keys to press. Ensures only these modifiers are pressed during the operation. */
123
- modifiers: PlaywrightModifiersSchema.optional(),
124
- /**
125
- * @deprecated This option has no effect.
126
- * Actions that initiate navigations are waiting for these navigations to happen.
127
- */
128
- noWaitAfter: z.boolean().optional(),
129
- /** A point to use relative to the top-left corner of element padding box. */
130
- position: PlaywrightPositionSchema.optional(),
131
- /**
132
- * Maximum time in milliseconds. Defaults to 0 (no timeout).
133
- * Can be changed via actionTimeout in config or browserContext.setDefaultTimeout().
134
- */
135
- timeout: z.number().nonnegative().optional(),
136
- /**
137
- * When set, performs actionability checks only without performing the action.
138
- * Defaults to false. Useful to wait until element is ready.
139
- * Note: keyboard modifiers will be pressed regardless of trial.
140
- * @since v1.11
141
- */
142
- trial: z.boolean().optional(),
143
- });
144
- // ============================================================================
145
- // Double Click Options
146
- // ============================================================================
147
- /**
148
- * Options for dblclick() method
149
- * @see https://playwright.dev/docs/api/class-locator#locator-dblclick
150
- */
151
- export const PlaywrightDblclickOptionsSchema = z.object({
152
- /** Mouse button to use. Defaults to 'left'. */
153
- button: PlaywrightMouseButtonSchema.optional(),
154
- /** Time to wait between mousedown and mouseup in milliseconds. Defaults to 0. */
155
- delay: z.number().nonnegative().optional(),
156
- /** Whether to bypass actionability checks. Defaults to false. */
157
- force: z.boolean().optional(),
158
- /** Modifier keys to press. */
159
- modifiers: PlaywrightModifiersSchema.optional(),
160
- /** @deprecated This option has no effect. */
161
- noWaitAfter: z.boolean().optional(),
162
- /** A point to use relative to the top-left corner of element padding box. */
163
- position: PlaywrightPositionSchema.optional(),
164
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
165
- timeout: z.number().nonnegative().optional(),
166
- /**
167
- * When set, performs actionability checks only without performing the action.
168
- * @since v1.11
169
- */
170
- trial: z.boolean().optional(),
171
- });
172
- // ============================================================================
173
- // Fill Options
174
- // ============================================================================
175
- /**
176
- * Options for fill() method
177
- * @see https://playwright.dev/docs/api/class-locator#locator-fill
178
- */
179
- export const PlaywrightFillOptionsSchema = z.object({
180
- /**
181
- * Whether to bypass actionability checks. Defaults to false.
182
- * @since v1.13
183
- */
184
- force: z.boolean().optional(),
185
- /** @deprecated This option has no effect. */
186
- noWaitAfter: z.boolean().optional(),
187
- /**
188
- * Maximum time in milliseconds. Defaults to 0 (no timeout).
189
- * The default value can be changed via actionTimeout in config,
190
- * browserContext.setDefaultTimeout() or page.setDefaultTimeout().
191
- */
192
- timeout: z.number().nonnegative().optional(),
193
- });
194
- // ============================================================================
195
- // Goto (Navigation) Options
196
- // ============================================================================
197
- /**
198
- * Options for page.goto() and frame.goto() methods
199
- * @see https://playwright.dev/docs/api/class-page#page-goto
200
- * @see https://playwright.dev/docs/api/class-frame#frame-goto
201
- */
202
- export const PlaywrightGotoOptionsSchema = z.object({
203
- /** Referer header to use for the navigation request. */
204
- referer: z.string().optional(),
205
- /**
206
- * Maximum operation time in milliseconds. Defaults to 0 (no timeout).
207
- * The default value can be changed via navigationTimeout in config,
208
- * browserContext.setDefaultNavigationTimeout() or page.setDefaultNavigationTimeout().
209
- */
210
- timeout: z.number().nonnegative().optional(),
211
- /**
212
- * When to consider operation succeeded. Defaults to 'load'.
213
- * - 'load': wait for the load event
214
- * - 'domcontentloaded': wait for DOMContentLoaded event
215
- * - 'networkidle': wait until no network connections for 500ms
216
- * - 'commit': wait for response received and document started loading
217
- */
218
- waitUntil: PlaywrightWaitUntilSchema.optional(),
219
- });
220
- // ============================================================================
221
- // Navigation Options (for goBack, goForward, reload)
222
- // ============================================================================
223
- /**
224
- * Options for navigation methods (goBack, goForward, reload)
225
- * @see https://playwright.dev/docs/api/class-page#page-go-back
226
- * @see https://playwright.dev/docs/api/class-page#page-go-forward
227
- * @see https://playwright.dev/docs/api/class-page#page-reload
228
- */
229
- export const PlaywrightNavigationOptionsSchema = z.object({
230
- /**
231
- * Maximum operation time in milliseconds. Defaults to 0 (no timeout).
232
- * The default value can be changed via navigationTimeout in config.
233
- */
234
- timeout: z.number().nonnegative().optional(),
235
- /** When to consider operation succeeded. Defaults to 'load'. */
236
- waitUntil: PlaywrightWaitUntilSchema.optional(),
237
- });
238
- // Aliases for specific navigation methods
239
- export const PlaywrightGoBackOptionsSchema = PlaywrightNavigationOptionsSchema;
240
- export const PlaywrightGoForwardOptionsSchema = PlaywrightNavigationOptionsSchema;
241
- export const PlaywrightReloadOptionsSchema = PlaywrightNavigationOptionsSchema;
242
- // ============================================================================
243
- // WaitForSelector Options
244
- // ============================================================================
245
- /**
246
- * Options for waitForSelector() method
247
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-selector
248
- * @see https://playwright.dev/docs/api/class-frame#frame-wait-for-selector
249
- */
250
- export const PlaywrightWaitForSelectorOptionsSchema = z.object({
251
- /**
252
- * State to wait for. Defaults to 'visible'.
253
- * - 'attached': wait for element to be present in DOM
254
- * - 'detached': wait for element to not be present in DOM
255
- * - 'visible': wait for element to have non-empty bounding box and no visibility:hidden
256
- * - 'hidden': wait for element to be detached, empty bounding box, or visibility:hidden
257
- */
258
- state: PlaywrightWaitForSelectorStateSchema.optional(),
259
- /**
260
- * When true, requires selector to resolve to a single element.
261
- * If selector resolves to multiple elements, throws an exception.
262
- * @since v1.14
263
- */
264
- strict: z.boolean().optional(),
265
- /**
266
- * Maximum time in milliseconds. Defaults to 30000 (30 seconds).
267
- * Pass 0 to disable timeout.
268
- */
269
- timeout: z.number().nonnegative().optional(),
270
- });
271
- // ============================================================================
272
- // Screenshot Options
273
- // ============================================================================
274
- /**
275
- * Screenshot clip region
276
- * @see https://playwright.dev/docs/api/class-page#page-screenshot
277
- */
278
- export const PlaywrightScreenshotClipSchema = z.object({
279
- /** x-coordinate of top-left corner of clip area */
280
- x: z.number(),
281
- /** y-coordinate of top-left corner of clip area */
282
- y: z.number(),
283
- /** Width of clipping area */
284
- width: z.number().positive(),
285
- /** Height of clipping area */
286
- height: z.number().positive(),
287
- });
288
- /**
289
- * Options for screenshot() method
290
- * @see https://playwright.dev/docs/api/class-page#page-screenshot
291
- * @see https://playwright.dev/docs/api/class-locator#locator-screenshot
292
- */
293
- export const PlaywrightScreenshotOptionsSchema = z.object({
294
- /**
295
- * Controls CSS animations and transitions.
296
- * - 'disabled': finite animations are fast-forwarded to completion, infinite animations are canceled
297
- * - 'allow': animations proceed normally
298
- * Defaults to 'allow'.
299
- */
300
- animations: z.enum(['disabled', 'allow']).optional(),
301
- /**
302
- * Controls text caret visibility.
303
- * - 'hide': hides the text caret
304
- * - 'initial': shows caret as is
305
- * Defaults to 'hide'.
306
- */
307
- caret: z.enum(['hide', 'initial']).optional(),
308
- /** Specifies clipping region for the screenshot. */
309
- clip: PlaywrightScreenshotClipSchema.optional(),
310
- /**
311
- * When true, captures the full scrollable page instead of visible viewport.
312
- * Defaults to false.
313
- */
314
- fullPage: z.boolean().optional(),
315
- /**
316
- * List of locator selectors to mask when taking screenshot.
317
- * Masked elements are overlaid with pink box #FF00FF (or custom maskColor).
318
- * Note: In RPC, these are serialized as selector strings.
319
- */
320
- mask: z.array(z.string()).optional(),
321
- /**
322
- * CSS color format for overlay box of masked elements.
323
- * Defaults to pink #FF00FF.
324
- * @since v1.35
325
- */
326
- maskColor: z.string().optional(),
327
- /**
328
- * Hides default white background allowing transparent screenshots.
329
- * Not applicable to JPEG. Defaults to false.
330
- */
331
- omitBackground: z.boolean().optional(),
332
- /**
333
- * File path to save the image. Type inferred from extension.
334
- * Relative paths resolved from current working directory.
335
- */
336
- path: z.string().optional(),
337
- /**
338
- * Image quality between 0-100.
339
- * Not applicable to PNG images.
340
- */
341
- quality: z.number().int().min(0).max(100).optional(),
342
- /**
343
- * Scale mode for the screenshot.
344
- * - 'css': screenshot uses CSS pixel dimensions
345
- * - 'device': screenshot uses device pixel dimensions
346
- * Defaults to 'device'.
347
- */
348
- scale: z.enum(['css', 'device']).optional(),
349
- /**
350
- * Custom CSS stylesheet to apply before taking screenshot.
351
- * @since v1.40
352
- */
353
- style: z.string().optional(),
354
- /** Maximum time in milliseconds. Defaults to 30000 (30 seconds). */
355
- timeout: z.number().nonnegative().optional(),
356
- /**
357
- * Image format type.
358
- * - 'png': lossless compression
359
- * - 'jpeg': lossy compression (supports quality option)
360
- * Defaults to 'png'.
361
- */
362
- type: z.enum(['png', 'jpeg']).optional(),
363
- });
364
- // ============================================================================
365
- // Type (pressSequentially) Options
366
- // ============================================================================
367
- /**
368
- * Options for type() / pressSequentially() method
369
- * @see https://playwright.dev/docs/api/class-locator#locator-press-sequentially
370
- * @see https://playwright.dev/docs/api/class-keyboard#keyboard-type
371
- */
372
- export const PlaywrightTypeOptionsSchema = z.object({
373
- /**
374
- * Time to wait between key presses in milliseconds.
375
- * Defaults to 0 (instant typing).
376
- */
377
- delay: z.number().nonnegative().optional(),
378
- /** @deprecated This option has no effect. */
379
- noWaitAfter: z.boolean().optional(),
380
- /**
381
- * Maximum time in milliseconds. Defaults to 30000 (30 seconds).
382
- * Pass 0 to disable timeout.
383
- */
384
- timeout: z.number().nonnegative().optional(),
385
- });
386
- // Alias for pressSequentially
387
- export const PlaywrightPressSequentiallyOptionsSchema = PlaywrightTypeOptionsSchema;
388
- // ============================================================================
389
- // Hover Options
390
- // ============================================================================
391
- /**
392
- * Options for hover() method
393
- * @see https://playwright.dev/docs/api/class-locator#locator-hover
394
- * @see https://playwright.dev/docs/api/class-page#page-hover
395
- */
396
- export const PlaywrightHoverOptionsSchema = z.object({
397
- /** Whether to bypass actionability checks. Defaults to false. */
398
- force: z.boolean().optional(),
399
- /** Modifier keys to press during hover. */
400
- modifiers: PlaywrightModifiersSchema.optional(),
401
- /** @deprecated This option has no effect. */
402
- noWaitAfter: z.boolean().optional(),
403
- /** A point to use relative to the top-left corner of element padding box. */
404
- position: PlaywrightPositionSchema.optional(),
405
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
406
- timeout: z.number().nonnegative().optional(),
407
- /**
408
- * When set, performs actionability checks only without performing the action.
409
- * @since v1.11
410
- */
411
- trial: z.boolean().optional(),
412
- });
413
- // ============================================================================
414
- // Select Option(s) Options
415
- // ============================================================================
416
- /**
417
- * Value specification for selectOption
418
- * @see https://playwright.dev/docs/api/class-locator#locator-select-option
419
- */
420
- export const PlaywrightSelectOptionValueSchema = z.object({
421
- /** Matches by option.value */
422
- value: z.string().optional(),
423
- /** Matches by option.label */
424
- label: z.string().optional(),
425
- /** Matches by the option index (0-based) */
426
- index: z.number().int().nonnegative().optional(),
427
- });
428
- /**
429
- * Options for selectOption() method
430
- * @see https://playwright.dev/docs/api/class-locator#locator-select-option
431
- * @see https://playwright.dev/docs/api/class-page#page-select-option
432
- */
433
- export const PlaywrightSelectOptionsSchema = z.object({
434
- /**
435
- * Whether to bypass actionability checks. Defaults to false.
436
- * @since v1.13
437
- */
438
- force: z.boolean().optional(),
439
- /** @deprecated This option has no effect. */
440
- noWaitAfter: z.boolean().optional(),
441
- /**
442
- * When true, requires selector to resolve to a single element.
443
- * @since v1.14
444
- */
445
- strict: z.boolean().optional(),
446
- /**
447
- * Maximum time in milliseconds. Defaults to 0 (no timeout).
448
- */
449
- timeout: z.number().nonnegative().optional(),
450
- });
451
- // ============================================================================
452
- // Press Key Options
453
- // ============================================================================
454
- /**
455
- * Options for press() method (keyboard key press)
456
- * @see https://playwright.dev/docs/api/class-locator#locator-press
457
- * @see https://playwright.dev/docs/api/class-keyboard#keyboard-press
458
- */
459
- export const PlaywrightPressOptionsSchema = z.object({
460
- /** Time to wait between keydown and keyup in milliseconds. Defaults to 0. */
461
- delay: z.number().nonnegative().optional(),
462
- /** @deprecated This option has no effect. */
463
- noWaitAfter: z.boolean().optional(),
464
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
465
- timeout: z.number().nonnegative().optional(),
466
- });
467
- // ============================================================================
468
- // Check/Uncheck Options
469
- // ============================================================================
470
- /**
471
- * Options for check() and uncheck() methods
472
- * @see https://playwright.dev/docs/api/class-locator#locator-check
473
- * @see https://playwright.dev/docs/api/class-locator#locator-uncheck
474
- */
475
- export const PlaywrightCheckOptionsSchema = z.object({
476
- /** Whether to bypass actionability checks. Defaults to false. */
477
- force: z.boolean().optional(),
478
- /** @deprecated This option has no effect. */
479
- noWaitAfter: z.boolean().optional(),
480
- /** A point to use relative to the top-left corner of element padding box. */
481
- position: PlaywrightPositionSchema.optional(),
482
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
483
- timeout: z.number().nonnegative().optional(),
484
- /**
485
- * When set, performs actionability checks only without performing the action.
486
- * @since v1.11
487
- */
488
- trial: z.boolean().optional(),
489
- });
490
- // Alias for uncheck
491
- export const PlaywrightUncheckOptionsSchema = PlaywrightCheckOptionsSchema;
492
- // ============================================================================
493
- // Set Checked Options
494
- // ============================================================================
495
- /**
496
- * Options for setChecked() method
497
- * @see https://playwright.dev/docs/api/class-locator#locator-set-checked
498
- */
499
- export const PlaywrightSetCheckedOptionsSchema = z.object({
500
- /** Whether to bypass actionability checks. Defaults to false. */
501
- force: z.boolean().optional(),
502
- /** @deprecated This option has no effect. */
503
- noWaitAfter: z.boolean().optional(),
504
- /** A point to use relative to the top-left corner of element padding box. */
505
- position: PlaywrightPositionSchema.optional(),
506
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
507
- timeout: z.number().nonnegative().optional(),
508
- /**
509
- * When set, performs actionability checks only without performing the action.
510
- * @since v1.11
511
- */
512
- trial: z.boolean().optional(),
513
- });
514
- // ============================================================================
515
- // Focus Options
516
- // ============================================================================
517
- /**
518
- * Options for focus() method
519
- * @see https://playwright.dev/docs/api/class-locator#locator-focus
520
- */
521
- export const PlaywrightFocusOptionsSchema = z.object({
522
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
523
- timeout: z.number().nonnegative().optional(),
524
- });
525
- // ============================================================================
526
- // Blur Options
527
- // ============================================================================
528
- /**
529
- * Options for blur() method
530
- * @see https://playwright.dev/docs/api/class-locator#locator-blur
531
- */
532
- export const PlaywrightBlurOptionsSchema = z.object({
533
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
534
- timeout: z.number().nonnegative().optional(),
535
- });
536
- // ============================================================================
537
- // Tap Options
538
- // ============================================================================
539
- /**
540
- * Options for tap() method (touch screen tap)
541
- * @see https://playwright.dev/docs/api/class-locator#locator-tap
542
- */
543
- export const PlaywrightTapOptionsSchema = z.object({
544
- /** Whether to bypass actionability checks. Defaults to false. */
545
- force: z.boolean().optional(),
546
- /** Modifier keys to press during tap. */
547
- modifiers: PlaywrightModifiersSchema.optional(),
548
- /** @deprecated This option has no effect. */
549
- noWaitAfter: z.boolean().optional(),
550
- /** A point to use relative to the top-left corner of element padding box. */
551
- position: PlaywrightPositionSchema.optional(),
552
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
553
- timeout: z.number().nonnegative().optional(),
554
- /**
555
- * When set, performs actionability checks only without performing the action.
556
- * @since v1.11
557
- */
558
- trial: z.boolean().optional(),
559
- });
560
- // ============================================================================
561
- // Scroll Into View Options
562
- // ============================================================================
563
- /**
564
- * Options for scrollIntoViewIfNeeded() method
565
- * @see https://playwright.dev/docs/api/class-locator#locator-scroll-into-view-if-needed
566
- */
567
- export const PlaywrightScrollIntoViewOptionsSchema = z.object({
568
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
569
- timeout: z.number().nonnegative().optional(),
570
- });
571
- // ============================================================================
572
- // Drag Options
573
- // ============================================================================
574
- /**
575
- * Options for dragTo() method
576
- * @see https://playwright.dev/docs/api/class-locator#locator-drag-to
577
- */
578
- export const PlaywrightDragToOptionsSchema = z.object({
579
- /** Whether to bypass actionability checks. Defaults to false. */
580
- force: z.boolean().optional(),
581
- /** @deprecated This option has no effect. */
582
- noWaitAfter: z.boolean().optional(),
583
- /** Position on source element to start drag from. */
584
- sourcePosition: PlaywrightPositionSchema.optional(),
585
- /** Position on target element to drop at. */
586
- targetPosition: PlaywrightPositionSchema.optional(),
587
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
588
- timeout: z.number().nonnegative().optional(),
589
- /**
590
- * When set, performs actionability checks only without performing the action.
591
- * @since v1.11
592
- */
593
- trial: z.boolean().optional(),
594
- });
595
- // ============================================================================
596
- // Set Input Files Options
597
- // ============================================================================
598
- /**
599
- * Options for setInputFiles() method
600
- * @see https://playwright.dev/docs/api/class-locator#locator-set-input-files
601
- */
602
- export const PlaywrightSetInputFilesOptionsSchema = z.object({
603
- /** @deprecated This option has no effect. */
604
- noWaitAfter: z.boolean().optional(),
605
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
606
- timeout: z.number().nonnegative().optional(),
607
- });
608
- // ============================================================================
609
- // WaitFor Options
610
- // ============================================================================
611
- /**
612
- * Options for locator.waitFor() method
613
- * @see https://playwright.dev/docs/api/class-locator#locator-wait-for
614
- */
615
- export const PlaywrightWaitForOptionsSchema = z.object({
616
- /** State to wait for. Defaults to 'visible'. */
617
- state: PlaywrightWaitForSelectorStateSchema.optional(),
618
- /**
619
- * Maximum time in milliseconds. Defaults to 0 (no timeout).
620
- */
621
- timeout: z.number().nonnegative().optional(),
622
- });
623
- // ============================================================================
624
- // WaitForLoadState Options
625
- // ============================================================================
626
- /**
627
- * Load state values
628
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-load-state
629
- */
630
- export const PlaywrightLoadStateSchema = z.enum([
631
- 'load', // Wait for the load event
632
- 'domcontentloaded', // Wait for DOMContentLoaded event
633
- 'networkidle', // Wait until no network connections for 500ms
634
- ]);
635
- /**
636
- * Options for waitForLoadState() method
637
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-load-state
638
- */
639
- export const PlaywrightWaitForLoadStateOptionsSchema = z.object({
640
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
641
- timeout: z.number().nonnegative().optional(),
642
- });
643
- // ============================================================================
644
- // WaitForURL Options
645
- // ============================================================================
646
- /**
647
- * Options for waitForURL() method
648
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-url
649
- */
650
- export const PlaywrightWaitForURLOptionsSchema = z.object({
651
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
652
- timeout: z.number().nonnegative().optional(),
653
- /** When to consider operation succeeded. Defaults to 'load'. */
654
- waitUntil: PlaywrightWaitUntilSchema.optional(),
655
- });
656
- // ============================================================================
657
- // WaitForNavigation Options
658
- // ============================================================================
659
- /**
660
- * Options for waitForNavigation() method
661
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-navigation
662
- */
663
- export const PlaywrightWaitForNavigationOptionsSchema = z.object({
664
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
665
- timeout: z.number().nonnegative().optional(),
666
- /** URL pattern to wait for (string, RegExp, or predicate function). */
667
- url: z.string().optional(),
668
- /** When to consider operation succeeded. Defaults to 'load'. */
669
- waitUntil: PlaywrightWaitUntilSchema.optional(),
670
- });
671
- // ============================================================================
672
- // Evaluate Options
673
- // ============================================================================
674
- /**
675
- * Options for evaluate() method
676
- * @see https://playwright.dev/docs/api/class-page#page-evaluate
677
- */
678
- export const PlaywrightEvaluateOptionsSchema = z.object({
679
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
680
- timeout: z.number().nonnegative().optional(),
681
- });
682
- // ============================================================================
683
- // Inner Text/HTML/Text Content Options
684
- // ============================================================================
685
- /**
686
- * Options for textContent(), innerText(), innerHTML() methods
687
- * @see https://playwright.dev/docs/api/class-locator#locator-text-content
688
- */
689
- export const PlaywrightTextContentOptionsSchema = z.object({
690
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
691
- timeout: z.number().nonnegative().optional(),
692
- });
693
- export const PlaywrightInnerTextOptionsSchema = PlaywrightTextContentOptionsSchema;
694
- export const PlaywrightInnerHTMLOptionsSchema = PlaywrightTextContentOptionsSchema;
695
- // ============================================================================
696
- // Input Value Options
697
- // ============================================================================
698
- /**
699
- * Options for inputValue() method
700
- * @see https://playwright.dev/docs/api/class-locator#locator-input-value
701
- */
702
- export const PlaywrightInputValueOptionsSchema = z.object({
703
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
704
- timeout: z.number().nonnegative().optional(),
705
- });
706
- // ============================================================================
707
- // Get Attribute Options
708
- // ============================================================================
709
- /**
710
- * Options for getAttribute() method
711
- * @see https://playwright.dev/docs/api/class-locator#locator-get-attribute
712
- */
713
- export const PlaywrightGetAttributeOptionsSchema = z.object({
714
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
715
- timeout: z.number().nonnegative().optional(),
716
- });
717
- // ============================================================================
718
- // Is Visible/Enabled/Checked/Disabled/Editable/Hidden Options
719
- // ============================================================================
720
- /**
721
- * Options for isVisible(), isEnabled(), isChecked(), etc. methods
722
- * @see https://playwright.dev/docs/api/class-locator#locator-is-visible
723
- */
724
- export const PlaywrightIsOptionsSchema = z.object({
725
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
726
- timeout: z.number().nonnegative().optional(),
727
- });
728
- // ============================================================================
729
- // Bounding Box Options
730
- // ============================================================================
731
- /**
732
- * Options for boundingBox() method
733
- * @see https://playwright.dev/docs/api/class-locator#locator-bounding-box
734
- */
735
- export const PlaywrightBoundingBoxOptionsSchema = z.object({
736
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
737
- timeout: z.number().nonnegative().optional(),
738
- });
739
- // ============================================================================
740
- // Mouse Options
741
- // ============================================================================
742
- /**
743
- * Options for mouse.click() method
744
- * @see https://playwright.dev/docs/api/class-mouse#mouse-click
745
- */
746
- export const PlaywrightMouseClickOptionsSchema = z.object({
747
- /** Mouse button to use. Defaults to 'left'. */
748
- button: PlaywrightMouseButtonSchema.optional(),
749
- /** Number of clicks. Defaults to 1. */
750
- clickCount: z.number().int().positive().optional(),
751
- /** Time to wait between mousedown and mouseup in milliseconds. Defaults to 0. */
752
- delay: z.number().nonnegative().optional(),
753
- });
754
- /**
755
- * Options for mouse.dblclick() method
756
- * @see https://playwright.dev/docs/api/class-mouse#mouse-dblclick
757
- */
758
- export const PlaywrightMouseDblclickOptionsSchema = z.object({
759
- /** Mouse button to use. Defaults to 'left'. */
760
- button: PlaywrightMouseButtonSchema.optional(),
761
- /** Time to wait between mousedown and mouseup in milliseconds. Defaults to 0. */
762
- delay: z.number().nonnegative().optional(),
763
- });
764
- /**
765
- * Options for mouse.move() method
766
- * @see https://playwright.dev/docs/api/class-mouse#mouse-move
767
- */
768
- export const PlaywrightMouseMoveOptionsSchema = z.object({
769
- /** Number of intermediate mousemove events. Defaults to 1. */
770
- steps: z.number().int().positive().optional(),
771
- });
772
- /**
773
- * Options for mouse.down() and mouse.up() methods
774
- * @see https://playwright.dev/docs/api/class-mouse#mouse-down
775
- */
776
- export const PlaywrightMouseDownOptionsSchema = z.object({
777
- /** Mouse button to use. Defaults to 'left'. */
778
- button: PlaywrightMouseButtonSchema.optional(),
779
- /** Number of clicks. Defaults to 1. */
780
- clickCount: z.number().int().positive().optional(),
781
- });
782
- export const PlaywrightMouseUpOptionsSchema = PlaywrightMouseDownOptionsSchema;
783
- // Alias for down/up combined (used by some generated code)
784
- export const PlaywrightMouseDownUpOptionsSchema = PlaywrightMouseDownOptionsSchema;
785
- /**
786
- * Options for mouse.wheel() method
787
- * @see https://playwright.dev/docs/api/class-mouse#mouse-wheel
788
- */
789
- export const PlaywrightMouseWheelOptionsSchema = z.object({
790
- /** Horizontal scroll delta. */
791
- deltaX: z.number().optional(),
792
- /** Vertical scroll delta. */
793
- deltaY: z.number().optional(),
794
- });
795
- // ============================================================================
796
- // Keyboard Options
797
- // ============================================================================
798
- /**
799
- * Options for keyboard.type() method
800
- * @see https://playwright.dev/docs/api/class-keyboard#keyboard-type
801
- */
802
- export const PlaywrightKeyboardTypeOptionsSchema = z.object({
803
- /** Time to wait between key presses in milliseconds. Defaults to 0. */
804
- delay: z.number().nonnegative().optional(),
805
- });
806
- /**
807
- * Options for keyboard.press() method
808
- * @see https://playwright.dev/docs/api/class-keyboard#keyboard-press
809
- */
810
- export const PlaywrightKeyboardPressOptionsSchema = z.object({
811
- /** Time to wait between keydown and keyup in milliseconds. Defaults to 0. */
812
- delay: z.number().nonnegative().optional(),
813
- });
814
- // ============================================================================
815
- // PDF Options
816
- // ============================================================================
817
- /**
818
- * PDF margin configuration
819
- * @see https://playwright.dev/docs/api/class-page#page-pdf
820
- */
821
- export const PlaywrightPDFMarginSchema = z.object({
822
- /** Top margin (number in pixels or string with unit) */
823
- top: z.union([z.string(), z.number()]).optional(),
824
- /** Right margin (number in pixels or string with unit) */
825
- right: z.union([z.string(), z.number()]).optional(),
826
- /** Bottom margin (number in pixels or string with unit) */
827
- bottom: z.union([z.string(), z.number()]).optional(),
828
- /** Left margin (number in pixels or string with unit) */
829
- left: z.union([z.string(), z.number()]).optional(),
830
- });
831
- /**
832
- * Options for page.pdf() method
833
- * @see https://playwright.dev/docs/api/class-page#page-pdf
834
- */
835
- export const PlaywrightPDFOptionsSchema = z.object({
836
- /** Display header and footer. Defaults to false. */
837
- displayHeaderFooter: z.boolean().optional(),
838
- /** HTML template for the footer. */
839
- footerTemplate: z.string().optional(),
840
- /**
841
- * Paper format. If set, takes priority over width/height.
842
- * Defaults to 'Letter'.
843
- */
844
- format: z.string().optional(),
845
- /** HTML template for the header. */
846
- headerTemplate: z.string().optional(),
847
- /** Paper height (number in pixels or string with unit). */
848
- height: z.union([z.string(), z.number()]).optional(),
849
- /** Paper orientation. Defaults to false (portrait). */
850
- landscape: z.boolean().optional(),
851
- /** Paper margins. */
852
- margin: PlaywrightPDFMarginSchema.optional(),
853
- /** Hides default white background. Defaults to false. */
854
- omitBackground: z.boolean().optional(),
855
- /**
856
- * Generate document outline for tagged PDF.
857
- * @since v1.42
858
- */
859
- outline: z.boolean().optional(),
860
- /** Paper ranges to print (e.g., '1-5, 8, 11-13'). Defaults to all pages. */
861
- pageRanges: z.string().optional(),
862
- /** File path to save PDF. Relative paths resolved from cwd. */
863
- path: z.string().optional(),
864
- /** Give any CSS @page size declared in the page priority over format. Defaults to false. */
865
- preferCSSPageSize: z.boolean().optional(),
866
- /** Print background graphics. Defaults to false. */
867
- printBackground: z.boolean().optional(),
868
- /** Scale of the webpage rendering. Defaults to 1. Range 0.1-2. */
869
- scale: z.number().min(0.1).max(2).optional(),
870
- /**
871
- * Generate tagged (accessible) PDF. Defaults to false.
872
- * @since v1.42
873
- */
874
- tagged: z.boolean().optional(),
875
- /** Paper width (number in pixels or string with unit). */
876
- width: z.union([z.string(), z.number()]).optional(),
877
- });
878
- // ============================================================================
879
- // Cookie Types
880
- // ============================================================================
881
- /**
882
- * Cookie SameSite attribute
883
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-add-cookies
884
- */
885
- export const PlaywrightCookieSameSiteSchema = z.enum(['Strict', 'Lax', 'None']);
886
- /**
887
- * Cookie for addCookies() method
888
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-add-cookies
889
- */
890
- export const PlaywrightCookieSchema = z.object({
891
- /** Cookie name */
892
- name: z.string(),
893
- /** Cookie value */
894
- value: z.string(),
895
- /** Domain. Either domain or url must be specified. */
896
- domain: z.string().optional(),
897
- /** Path. Defaults to '/'. */
898
- path: z.string().optional(),
899
- /** Unix time in seconds. -1 for session cookie. */
900
- expires: z.number().optional(),
901
- /** HttpOnly flag. Defaults to false. */
902
- httpOnly: z.boolean().optional(),
903
- /** Secure flag. Defaults to false. */
904
- secure: z.boolean().optional(),
905
- /** SameSite attribute. Defaults to 'None'. */
906
- sameSite: PlaywrightCookieSameSiteSchema.optional(),
907
- /** URL. Either domain or url must be specified. */
908
- url: z.string().optional(),
909
- });
910
- // ============================================================================
911
- // Geolocation
912
- // ============================================================================
913
- /**
914
- * Geolocation for context.setGeolocation()
915
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-set-geolocation
916
- */
917
- export const PlaywrightGeolocationSchema = z.object({
918
- /** Latitude between -90 and 90. */
919
- latitude: z.number().min(-90).max(90),
920
- /** Longitude between -180 and 180. */
921
- longitude: z.number().min(-180).max(180),
922
- /** Non-negative accuracy value. */
923
- accuracy: z.number().nonnegative().optional(),
924
- });
925
- // ============================================================================
926
- // HTTP Credentials
927
- // ============================================================================
928
- /**
929
- * HTTP credentials for context
930
- * @see https://playwright.dev/docs/api/class-browser#browser-new-context
931
- */
932
- export const PlaywrightHttpCredentialsSchema = z.object({
933
- /** Username */
934
- username: z.string(),
935
- /** Password */
936
- password: z.string(),
937
- /** Origin to send credentials for (optional) */
938
- origin: z.string().optional(),
939
- /**
940
- * Whether to send credentials eagerly
941
- * @since v1.42
942
- */
943
- send: z.enum(['always', 'unauthorized']).optional(),
944
- });
945
- // ============================================================================
946
- // Video Recording Options
947
- // ============================================================================
948
- /**
949
- * Video recording configuration
950
- * @see https://playwright.dev/docs/api/class-browser#browser-new-context
951
- */
952
- export const PlaywrightVideoOptionsSchema = z.object({
953
- /** Path to directory for video files */
954
- dir: z.string(),
955
- /** Video size. Defaults to viewport. */
956
- size: z
957
- .object({
958
- width: z.number().int().positive(),
959
- height: z.number().int().positive(),
960
- })
961
- .optional(),
962
- });
963
- // ============================================================================
964
- // Record HAR Options
965
- // ============================================================================
966
- /**
967
- * HAR recording configuration
968
- * @see https://playwright.dev/docs/api/class-browser#browser-new-context
969
- */
970
- export const PlaywrightRecordHarOptionsSchema = z.object({
971
- /** Path to HAR file */
972
- path: z.string(),
973
- /** HAR format mode */
974
- mode: z.enum(['full', 'minimal']).optional(),
975
- /** Content recording mode */
976
- content: z.enum(['omit', 'embed', 'attach']).optional(),
977
- /** URL filter (string glob or RegExp) */
978
- urlFilter: z.string().optional(),
979
- });
980
- // ============================================================================
981
- // Proxy Configuration
982
- // ============================================================================
983
- /**
984
- * Proxy settings
985
- * @see https://playwright.dev/docs/api/class-browser#browser-new-context
986
- */
987
- export const PlaywrightProxyOptionsSchema = z.object({
988
- /** Proxy server URL (required) */
989
- server: z.string(),
990
- /** Optional bypass list */
991
- bypass: z.string().optional(),
992
- /** Username for proxy authentication */
993
- username: z.string().optional(),
994
- /** Password for proxy authentication */
995
- password: z.string().optional(),
996
- });
997
- // ============================================================================
998
- // Browser Context Options
999
- // ============================================================================
1000
- /**
1001
- * Options for browser.newContext()
1002
- * @see https://playwright.dev/docs/api/class-browser#browser-new-context
1003
- */
1004
- export const PlaywrightNewContextOptionsSchema = z.object({
1005
- /** Accept downloads. Defaults to true. */
1006
- acceptDownloads: z.boolean().optional(),
1007
- /** Base URL for relative URLs */
1008
- baseURL: z.string().optional(),
1009
- /** Bypass Content-Security-Policy */
1010
- bypassCSP: z.boolean().optional(),
1011
- /** Color scheme emulation */
1012
- colorScheme: z.enum(['light', 'dark', 'no-preference', 'null']).optional(),
1013
- /** Device scale factor */
1014
- deviceScaleFactor: z.number().positive().optional(),
1015
- /** Extra HTTP headers */
1016
- extraHTTPHeaders: z.record(z.string(), z.string()).optional(),
1017
- /** Forced colors emulation */
1018
- forcedColors: z.enum(['active', 'none', 'null']).optional(),
1019
- /** Geolocation */
1020
- geolocation: PlaywrightGeolocationSchema.optional(),
1021
- /** Has touch support */
1022
- hasTouch: z.boolean().optional(),
1023
- /** HTTP credentials */
1024
- httpCredentials: PlaywrightHttpCredentialsSchema.optional(),
1025
- /** Ignore HTTPS errors */
1026
- ignoreHTTPSErrors: z.boolean().optional(),
1027
- /** Is mobile device */
1028
- isMobile: z.boolean().optional(),
1029
- /** Enable JavaScript. Defaults to true. */
1030
- javaScriptEnabled: z.boolean().optional(),
1031
- /** Locale (e.g., 'en-US') */
1032
- locale: z.string().optional(),
1033
- /** Offline mode */
1034
- offline: z.boolean().optional(),
1035
- /** Permissions to grant */
1036
- permissions: z.array(z.string()).optional(),
1037
- /** Proxy configuration */
1038
- proxy: PlaywrightProxyOptionsSchema.optional(),
1039
- /** HAR recording options */
1040
- recordHar: PlaywrightRecordHarOptionsSchema.optional(),
1041
- /** Video recording options */
1042
- recordVideo: PlaywrightVideoOptionsSchema.optional(),
1043
- /** Reduced motion emulation */
1044
- reducedMotion: z.enum(['reduce', 'no-preference', 'null']).optional(),
1045
- /** Screen dimensions */
1046
- screen: z
1047
- .object({
1048
- width: z.number().int().positive(),
1049
- height: z.number().int().positive(),
1050
- })
1051
- .optional(),
1052
- /** Service workers handling */
1053
- serviceWorkers: z.enum(['allow', 'block']).optional(),
1054
- /** Storage state (string path or object) */
1055
- storageState: z.union([z.string(), z.object({}).passthrough()]).optional(),
1056
- /** Emulate strict CSP on every page */
1057
- strictSelectors: z.boolean().optional(),
1058
- /** Timezone ID (e.g., 'America/New_York') */
1059
- timezoneId: z.string().optional(),
1060
- /** User agent string */
1061
- userAgent: z.string().optional(),
1062
- /** Viewport dimensions (null to disable) */
1063
- viewport: z.union([PlaywrightViewportSchema, z.null()]).optional(),
1064
- });
1065
- // ============================================================================
1066
- // Tracing Options (Chromium only)
1067
- // ============================================================================
1068
- /**
1069
- * Options for browser.startTracing()
1070
- * @see https://playwright.dev/docs/api/class-browser#browser-start-tracing
1071
- */
1072
- export const PlaywrightStartTracingOptionsSchema = z.object({
1073
- /** A path to write the trace file to. */
1074
- path: z.string().optional(),
1075
- /** Captures screenshots in the trace. */
1076
- screenshots: z.boolean().optional(),
1077
- /** Specify custom categories to use instead of default. */
1078
- categories: z.array(z.string()).optional(),
1079
- });
1080
- // ============================================================================
1081
- // Context Tracing Options
1082
- // ============================================================================
1083
- /**
1084
- * Options for tracing.start()
1085
- * @see https://playwright.dev/docs/api/class-tracing#tracing-start
1086
- */
1087
- export const PlaywrightTracingStartOptionsSchema = z.object({
1088
- /** Trace name to be shown in Trace Viewer. */
1089
- name: z.string().optional(),
1090
- /** Whether to capture screenshots during tracing. */
1091
- screenshots: z.boolean().optional(),
1092
- /** Whether to capture DOM snapshots on every action. */
1093
- snapshots: z.boolean().optional(),
1094
- /** Whether to include source files for trace actions. */
1095
- sources: z.boolean().optional(),
1096
- /** Trace title to be shown in Trace Viewer. */
1097
- title: z.string().optional(),
1098
- });
1099
- /**
1100
- * Options for tracing.stop()
1101
- * @see https://playwright.dev/docs/api/class-tracing#tracing-stop
1102
- */
1103
- export const PlaywrightTracingStopOptionsSchema = z.object({
1104
- /** Path to export the trace to. */
1105
- path: z.string().optional(),
1106
- });
1107
- // ============================================================================
1108
- // Coverage Options & Types
1109
- // ============================================================================
1110
- /**
1111
- * Options for coverage.startCSSCoverage()
1112
- * @see https://playwright.dev/docs/api/class-coverage#coverage-start-css-coverage
1113
- */
1114
- export const PlaywrightStartCSSCoverageOptionsSchema = z.object({
1115
- /** Whether to reset coverage on every navigation. Defaults to true. */
1116
- resetOnNavigation: z.boolean().optional(),
1117
- });
1118
- /**
1119
- * Options for coverage.startJSCoverage()
1120
- * @see https://playwright.dev/docs/api/class-coverage#coverage-start-js-coverage
1121
- */
1122
- export const PlaywrightStartJSCoverageOptionsSchema = z.object({
1123
- /** Whether to reset coverage on every navigation. Defaults to true. */
1124
- resetOnNavigation: z.boolean().optional(),
1125
- /** Whether anonymous scripts generated by the page should be reported. Defaults to false. */
1126
- reportAnonymousScripts: z.boolean().optional(),
1127
- });
1128
- /**
1129
- * CSS coverage entry returned by stopCSSCoverage()
1130
- * @see https://playwright.dev/docs/api/class-coverage#coverage-stop-css-coverage
1131
- */
1132
- export const PlaywrightCSSCoverageEntrySchema = z.object({
1133
- /** StyleSheet URL */
1134
- url: z.string(),
1135
- /** StyleSheet content, if available */
1136
- text: z.string().optional(),
1137
- /** StyleSheet ranges that were used (sorted and non-overlapping) */
1138
- ranges: z.array(z.object({
1139
- /** Start offset in text, inclusive */
1140
- start: z.number(),
1141
- /** End offset in text, exclusive */
1142
- end: z.number(),
1143
- })),
1144
- });
1145
- /**
1146
- * JS coverage entry returned by stopJSCoverage()
1147
- * @see https://playwright.dev/docs/api/class-coverage#coverage-stop-js-coverage
1148
- */
1149
- export const PlaywrightJSCoverageEntrySchema = z.object({
1150
- /** Script URL */
1151
- url: z.string(),
1152
- /** Script ID */
1153
- scriptId: z.string(),
1154
- /** Script content, if applicable */
1155
- source: z.string().optional(),
1156
- /** V8-specific coverage format */
1157
- functions: z.array(z.object({
1158
- /** Function name */
1159
- functionName: z.string(),
1160
- /** Whether block coverage is enabled */
1161
- isBlockCoverage: z.boolean(),
1162
- /** Coverage ranges */
1163
- ranges: z.array(z.object({
1164
- /** Execution count */
1165
- count: z.number(),
1166
- /** Start offset */
1167
- startOffset: z.number(),
1168
- /** End offset */
1169
- endOffset: z.number(),
1170
- })),
1171
- })),
1172
- });
1173
- // ============================================================================
1174
- // Dialog Options
1175
- // ============================================================================
1176
- /**
1177
- * Dialog type
1178
- * @see https://playwright.dev/docs/api/class-dialog
1179
- */
1180
- export const PlaywrightDialogTypeSchema = z.enum([
1181
- 'alert',
1182
- 'beforeunload',
1183
- 'confirm',
1184
- 'prompt',
1185
- ]);
1186
- // ============================================================================
1187
- // Console Message Types
1188
- // ============================================================================
1189
- /**
1190
- * Console message type
1191
- * @see https://playwright.dev/docs/api/class-consolemessage#console-message-type
1192
- */
1193
- export const PlaywrightConsoleMessageTypeSchema = z.enum([
1194
- 'log',
1195
- 'debug',
1196
- 'info',
1197
- 'error',
1198
- 'warning',
1199
- 'dir',
1200
- 'dirxml',
1201
- 'table',
1202
- 'trace',
1203
- 'clear',
1204
- 'startGroup',
1205
- 'startGroupCollapsed',
1206
- 'endGroup',
1207
- 'assert',
1208
- 'profile',
1209
- 'profileEnd',
1210
- 'count',
1211
- 'timeEnd',
1212
- ]);
1213
- /**
1214
- * Source location of a console message
1215
- * @see https://playwright.dev/docs/api/class-consolemessage#console-message-location
1216
- */
1217
- export const PlaywrightConsoleMessageLocationSchema = z.object({
1218
- /** URL of the resource */
1219
- url: z.string(),
1220
- /** 0-based line number in the resource */
1221
- lineNumber: z.number(),
1222
- /** 0-based column number in the resource */
1223
- columnNumber: z.number(),
1224
- });
1225
- // ============================================================================
1226
- // Bounding Box Result
1227
- // ============================================================================
1228
- /**
1229
- * Bounding box result from boundingBox() method
1230
- * @see https://playwright.dev/docs/api/class-locator#locator-bounding-box
1231
- */
1232
- export const PlaywrightBoundingBoxResultSchema = z.object({
1233
- /** x-coordinate */
1234
- x: z.number(),
1235
- /** y-coordinate */
1236
- y: z.number(),
1237
- /** Width */
1238
- width: z.number(),
1239
- /** Height */
1240
- height: z.number(),
1241
- });
1242
- // ============================================================================
1243
- // Locator Filter Options
1244
- // ============================================================================
1245
- /**
1246
- * Options for locator.filter() method
1247
- * @see https://playwright.dev/docs/api/class-locator#locator-filter
1248
- */
1249
- export const PlaywrightLocatorFilterOptionsSchema = z.object({
1250
- /** Filter by text content */
1251
- hasText: z.union([z.string(), z.instanceof(RegExp)]).optional(),
1252
- /** Filter by not having text content */
1253
- hasNotText: z.union([z.string(), z.instanceof(RegExp)]).optional(),
1254
- /** Filter by having matching descendant locator (serialized) */
1255
- has: z.string().optional(),
1256
- /** Filter by not having matching descendant locator (serialized) */
1257
- hasNot: z.string().optional(),
1258
- });
1259
- // ============================================================================
1260
- // Get By Role Options
1261
- // ============================================================================
1262
- /**
1263
- * Options for getByRole() method
1264
- * @see https://playwright.dev/docs/api/class-page#page-get-by-role
1265
- */
1266
- export const PlaywrightGetByRoleOptionsSchema = z.object({
1267
- /** Element is checked (checkbox, radio, switch). */
1268
- checked: z.boolean().optional(),
1269
- /** Element is disabled. */
1270
- disabled: z.boolean().optional(),
1271
- /** Exact name match. Defaults to false (substring match). */
1272
- exact: z.boolean().optional(),
1273
- /** Element is expanded (combobox, listbox, menu, tree). */
1274
- expanded: z.boolean().optional(),
1275
- /** Include hidden elements. Defaults to false. */
1276
- includeHidden: z.boolean().optional(),
1277
- /** Heading level (1-6). */
1278
- level: z.number().int().min(1).max(6).optional(),
1279
- /** Accessible name (string or RegExp). */
1280
- name: z.union([z.string(), z.instanceof(RegExp)]).optional(),
1281
- /** Element is pressed (toggle button). */
1282
- pressed: z.boolean().optional(),
1283
- /** Element is selected (option). */
1284
- selected: z.boolean().optional(),
1285
- });
1286
- // ============================================================================
1287
- // Get By Text/Label/Placeholder/AltText/Title Options
1288
- // ============================================================================
1289
- /**
1290
- * Options for getByText(), getByLabel(), getByPlaceholder(), getByAltText(), getByTitle() methods
1291
- * @see https://playwright.dev/docs/api/class-page#page-get-by-text
1292
- */
1293
- export const PlaywrightGetByTextOptionsSchema = z.object({
1294
- /** Exact match. Defaults to false. */
1295
- exact: z.boolean().optional(),
1296
- });
1297
- export const PlaywrightGetByLabelOptionsSchema = PlaywrightGetByTextOptionsSchema;
1298
- export const PlaywrightGetByPlaceholderOptionsSchema = PlaywrightGetByTextOptionsSchema;
1299
- export const PlaywrightGetByAltTextOptionsSchema = PlaywrightGetByTextOptionsSchema;
1300
- export const PlaywrightGetByTitleOptionsSchema = PlaywrightGetByTextOptionsSchema;
1301
- // ============================================================================
1302
- // Emulate Media Options
1303
- // ============================================================================
1304
- /**
1305
- * Options for page.emulateMedia() method
1306
- * @see https://playwright.dev/docs/api/class-page#page-emulate-media
1307
- */
1308
- export const PlaywrightEmulateMediaOptionsSchema = z.object({
1309
- /** Color scheme. Pass null to reset. */
1310
- colorScheme: z.enum(['light', 'dark', 'no-preference']).nullable().optional(),
1311
- /** Forced colors. Pass null to reset. */
1312
- forcedColors: z.enum(['active', 'none']).nullable().optional(),
1313
- /** Media type. Pass null to reset. */
1314
- media: z.enum(['screen', 'print']).nullable().optional(),
1315
- /** Reduced motion. Pass null to reset. */
1316
- reducedMotion: z.enum(['reduce', 'no-preference']).nullable().optional(),
1317
- });
1318
- // ============================================================================
1319
- // Route Options
1320
- // ============================================================================
1321
- /**
1322
- * Options for page.route() and context.route() methods
1323
- * @see https://playwright.dev/docs/api/class-page#page-route
1324
- */
1325
- export const PlaywrightRouteOptionsSchema = z.object({
1326
- /** How many times to match the route. Defaults to unlimited. */
1327
- times: z.number().int().positive().optional(),
1328
- });
1329
- // ============================================================================
1330
- // Add Script/Style Tag Options
1331
- // ============================================================================
1332
- /**
1333
- * Options for page.addScriptTag() method
1334
- * @see https://playwright.dev/docs/api/class-page#page-add-script-tag
1335
- */
1336
- export const PlaywrightAddScriptTagOptionsSchema = z.object({
1337
- /** Raw JavaScript content to be injected */
1338
- content: z.string().optional(),
1339
- /** Path to a JavaScript file */
1340
- path: z.string().optional(),
1341
- /** Script type. Use 'module' for ES modules. */
1342
- type: z.string().optional(),
1343
- /** URL of a remote script */
1344
- url: z.string().optional(),
1345
- });
1346
- /**
1347
- * Options for page.addStyleTag() method
1348
- * @see https://playwright.dev/docs/api/class-page#page-add-style-tag
1349
- */
1350
- export const PlaywrightAddStyleTagOptionsSchema = z.object({
1351
- /** Raw CSS content to be injected */
1352
- content: z.string().optional(),
1353
- /** Path to a CSS file */
1354
- path: z.string().optional(),
1355
- /** URL of a remote stylesheet */
1356
- url: z.string().optional(),
1357
- });
1358
- // ============================================================================
1359
- // Locator Chain (for RPC serialization)
1360
- // ============================================================================
1361
- /**
1362
- * Step in a locator chain for RPC serialization
1363
- */
1364
- export const PlaywrightLocatorChainStepSchema = z.object({
1365
- method: z.string(),
1366
- args: z.array(z.unknown()),
1367
- });
1368
- /**
1369
- * Serialized locator chain for RPC
1370
- */
1371
- export const PlaywrightSerializedLocatorChainSchema = z.object({
1372
- _locatorChain: z.array(PlaywrightLocatorChainStepSchema),
1373
- });
1374
- // ============================================================================
1375
- // Frame/Page Serialization
1376
- // ============================================================================
1377
- /**
1378
- * Serialized frame for RPC
1379
- */
1380
- export const PlaywrightFrameSchema = z.object({
1381
- frameId: z.string(),
1382
- url: z.string(),
1383
- name: z.string().optional(),
1384
- parentFrameId: z.string().optional(),
1385
- isDetached: z.boolean().optional(),
1386
- });
1387
- // ============================================================================
1388
- // Clear Options
1389
- // ============================================================================
1390
- /**
1391
- * Options for locator.clear() method
1392
- * @see https://playwright.dev/docs/api/class-locator#locator-clear
1393
- */
1394
- export const PlaywrightClearOptionsSchema = z.object({
1395
- /** Whether to bypass actionability checks. Defaults to false. */
1396
- force: z.boolean().optional(),
1397
- /** @deprecated This option has no effect. */
1398
- noWaitAfter: z.boolean().optional(),
1399
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
1400
- timeout: z.number().nonnegative().optional(),
1401
- });
1402
- // ============================================================================
1403
- // Count Options (locator.count() has no options, but for consistency)
1404
- // ============================================================================
1405
- // locator.count() takes no options
1406
- // ============================================================================
1407
- // All/First/Last/Nth Options (these have no options)
1408
- // ============================================================================
1409
- // locator.all(), first(), last(), nth() take no options
1410
- // ============================================================================
1411
- // Highlight Options
1412
- // ============================================================================
1413
- /**
1414
- * Options for locator.highlight() method
1415
- * Note: highlight() takes no options in current API
1416
- * @see https://playwright.dev/docs/api/class-locator#locator-highlight
1417
- */
1418
- // locator.highlight() takes no options
1419
- // ============================================================================
1420
- // WaitForEvent Options
1421
- // ============================================================================
1422
- /**
1423
- * Options for page.waitForEvent() method
1424
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-event
1425
- */
1426
- export const PlaywrightWaitForEventOptionsSchema = z.object({
1427
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
1428
- timeout: z.number().nonnegative().optional(),
1429
- });
1430
- // ============================================================================
1431
- // Accessibility Snapshot Options
1432
- // ============================================================================
1433
- /**
1434
- * Options for page.accessibility.snapshot() method
1435
- * @see https://playwright.dev/docs/api/class-accessibility#accessibility-snapshot
1436
- */
1437
- export const PlaywrightAccessibilitySnapshotOptionsSchema = z.object({
1438
- /** Prune uninteresting nodes from the tree. Defaults to true. */
1439
- interestingOnly: z.boolean().optional(),
1440
- /** Root element handle (serialized as selector string for RPC). */
1441
- root: z.string().optional(),
1442
- });
1443
- // ============================================================================
1444
- // APIRequest Options
1445
- // ============================================================================
1446
- /**
1447
- * File payload for multipart form data
1448
- * @see https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-fetch
1449
- */
1450
- export const PlaywrightFilePayloadSchema = z.object({
1451
- /** File name */
1452
- name: z.string(),
1453
- /** File MIME type */
1454
- mimeType: z.string(),
1455
- /** File content as base64 string (for RPC) or Buffer */
1456
- buffer: z.string(),
1457
- });
1458
- /**
1459
- * Multipart form data value
1460
- * Can be a string, number, boolean, or file payload
1461
- */
1462
- export const PlaywrightMultipartValueSchema = z.union([
1463
- z.string(),
1464
- z.number(),
1465
- z.boolean(),
1466
- PlaywrightFilePayloadSchema,
1467
- z.array(z.union([z.string(), PlaywrightFilePayloadSchema])),
1468
- ]);
1469
- /**
1470
- * Options for APIRequestContext HTTP methods (get, post, put, delete, patch, head, fetch)
1471
- * @see https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-fetch
1472
- */
1473
- export const PlaywrightAPIRequestOptionsSchema = z.object({
1474
- /**
1475
- * HTTP method to use. Defaults to 'GET' for fetch(), ignored for specific methods.
1476
- */
1477
- method: z.string().optional(),
1478
- /**
1479
- * Query parameters to be sent with the request.
1480
- * Can be an object or URLSearchParams-like string.
1481
- */
1482
- params: z.union([z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])), z.string()]).optional(),
1483
- /**
1484
- * Additional HTTP headers to be sent with the request.
1485
- */
1486
- headers: z.record(z.string(), z.string()).optional(),
1487
- /**
1488
- * Request body data. Can be a string, Buffer (base64 for RPC), or JSON-serializable object.
1489
- * If an object is provided, it will be serialized to JSON.
1490
- * Cannot be used together with `form` or `multipart`.
1491
- */
1492
- data: z.unknown().optional(),
1493
- /**
1494
- * Form data to be sent as application/x-www-form-urlencoded.
1495
- * Cannot be used together with `data` or `multipart`.
1496
- */
1497
- form: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
1498
- /**
1499
- * Form data to be sent as multipart/form-data.
1500
- * Supports file uploads via PlaywrightFilePayload objects.
1501
- * Cannot be used together with `data` or `form`.
1502
- */
1503
- multipart: z.record(z.string(), PlaywrightMultipartValueSchema).optional(),
1504
- /**
1505
- * Maximum time in milliseconds for the request.
1506
- * Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
1507
- */
1508
- timeout: z.number().nonnegative().optional(),
1509
- /**
1510
- * Whether to throw an error on response codes other than 2xx.
1511
- * Defaults to true.
1512
- */
1513
- failOnStatusCode: z.boolean().optional(),
1514
- /**
1515
- * Whether to ignore HTTPS errors during request.
1516
- * Defaults to false.
1517
- */
1518
- ignoreHTTPSErrors: z.boolean().optional(),
1519
- /**
1520
- * Maximum number of redirects to follow. 0 to not follow redirects.
1521
- * Defaults to 20.
1522
- */
1523
- maxRedirects: z.number().int().nonnegative().optional(),
1524
- /**
1525
- * Maximum number of times to retry the request on network errors.
1526
- * Defaults to 0 (no retries).
1527
- * @since v1.46
1528
- */
1529
- maxRetries: z.number().int().nonnegative().optional(),
1530
- });
1531
- /**
1532
- * Options for APIRequestContext.storageState() method
1533
- * @see https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-storage-state
1534
- */
1535
- export const PlaywrightStorageStateOptionsSchema = z.object({
1536
- /**
1537
- * File path to save the storage state to.
1538
- */
1539
- path: z.string().optional(),
1540
- /**
1541
- * Whether to include IndexedDB in the storage state snapshot.
1542
- * Defaults to false.
1543
- * @since v1.41
1544
- */
1545
- indexedDB: z.boolean().optional(),
1546
- });
1547
- /**
1548
- * Storage state returned by APIRequestContext.storageState()
1549
- * @see https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-storage-state
1550
- */
1551
- export const PlaywrightStorageStateSchema = z.object({
1552
- /** Cookies */
1553
- cookies: z.array(PlaywrightCookieSchema),
1554
- /** Origins with local storage */
1555
- origins: z.array(z.object({
1556
- origin: z.string(),
1557
- localStorage: z.array(z.object({
1558
- name: z.string(),
1559
- value: z.string(),
1560
- })),
1561
- })),
1562
- });
1563
- // ============================================================================
1564
- // Clear Cookies Options
1565
- // ============================================================================
1566
- /**
1567
- * Options for browserContext.clearCookies() method
1568
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-clear-cookies
1569
- */
1570
- export const PlaywrightClearCookiesOptionsSchema = z.object({
1571
- /** Clear only cookies with this specific name */
1572
- name: z.union([z.string(), z.instanceof(RegExp)]).optional(),
1573
- /** Clear only cookies for this specific domain */
1574
- domain: z.union([z.string(), z.instanceof(RegExp)]).optional(),
1575
- /** Clear only cookies with this specific path */
1576
- path: z.string().optional(),
1577
- });
1578
- // ============================================================================
1579
- // Permission Types
1580
- // ============================================================================
1581
- /**
1582
- * Browser permissions that can be granted
1583
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions
1584
- */
1585
- export const PlaywrightPermissionSchema = z.enum([
1586
- 'geolocation',
1587
- 'midi',
1588
- 'midi-sysex',
1589
- 'notifications',
1590
- 'camera',
1591
- 'microphone',
1592
- 'background-sync',
1593
- 'ambient-light-sensor',
1594
- 'accelerometer',
1595
- 'gyroscope',
1596
- 'magnetometer',
1597
- 'accessibility-events',
1598
- 'clipboard-read',
1599
- 'clipboard-write',
1600
- 'payment-handler',
1601
- 'storage-access',
1602
- ]);
1603
- /**
1604
- * Options for browserContext.grantPermissions() method
1605
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions
1606
- */
1607
- export const PlaywrightGrantPermissionsOptionsSchema = z.object({
1608
- /** Origin to grant permissions for */
1609
- origin: z.string().optional(),
1610
- });
1611
- // ============================================================================
1612
- // Add Locator Handler Options
1613
- // ============================================================================
1614
- /**
1615
- * Options for page.addLocatorHandler() method
1616
- * @see https://playwright.dev/docs/api/class-page#page-add-locator-handler
1617
- */
1618
- export const PlaywrightAddLocatorHandlerOptionsSchema = z.object({
1619
- /**
1620
- * If true, Playwright will not wait for the overlay that triggered
1621
- * the handler to become invisible after execution.
1622
- */
1623
- noWaitAfter: z.boolean().optional(),
1624
- /**
1625
- * Maximum number of times the handler should be run.
1626
- * By default, the handler runs unlimited times.
1627
- */
1628
- times: z.number().int().positive().optional(),
1629
- });
1630
- // ============================================================================
1631
- // Route From HAR Options
1632
- // ============================================================================
1633
- /**
1634
- * Options for page.routeFromHAR() and context.routeFromHAR() methods
1635
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-route-from-har
1636
- */
1637
- export const PlaywrightRouteFromHAROptionsSchema = z.object({
1638
- /** If 'abort', requests not in HAR are aborted. If 'fallback', falls through. Defaults to 'abort'. */
1639
- notFound: z.enum(['abort', 'fallback']).optional(),
1640
- /** If true, updates the HAR file instead of serving from it */
1641
- update: z.boolean().optional(),
1642
- /** URL pattern to match (glob, regex, or predicate) */
1643
- url: z.union([z.string(), z.instanceof(RegExp)]).optional(),
1644
- /** When updating, record mode: 'full' or 'minimal'. Defaults to 'minimal'. */
1645
- updateMode: z.enum(['full', 'minimal']).optional(),
1646
- /** When updating, content storage: 'embed' or 'attach'. */
1647
- updateContent: z.enum(['embed', 'attach']).optional(),
1648
- });
1649
- // ============================================================================
1650
- // Unroute All Options
1651
- // ============================================================================
1652
- /**
1653
- * Options for page.unrouteAll() and context.unrouteAll() methods
1654
- * @see https://playwright.dev/docs/api/class-browsercontext#browser-context-unroute-all
1655
- */
1656
- export const PlaywrightUnrouteAllOptionsSchema = z.object({
1657
- /** How to handle in-flight routes: 'wait' or 'ignoreErrors'. */
1658
- behavior: z.enum(['wait', 'ignoreErrors']).optional(),
1659
- });
1660
- // ============================================================================
1661
- // Browser Type (alias for casing compatibility)
1662
- // ============================================================================
1663
- /**
1664
- * HTTP credentials (alias with capital letters for compatibility)
1665
- * @see https://playwright.dev/docs/api/class-browser#browser-new-context
1666
- */
1667
- export const PlaywrightHTTPCredentialsSchema = PlaywrightHttpCredentialsSchema;
1668
- // ============================================================================
1669
- // ARIA Role
1670
- // ============================================================================
1671
- /**
1672
- * ARIA roles for getByRole() method
1673
- * @see https://playwright.dev/docs/api/class-page#page-get-by-role
1674
- * @see https://www.w3.org/TR/wai-aria-1.2/#roles
1675
- */
1676
- export const PlaywrightAriaRoleSchema = z.enum([
1677
- 'alert',
1678
- 'alertdialog',
1679
- 'application',
1680
- 'article',
1681
- 'banner',
1682
- 'blockquote',
1683
- 'button',
1684
- 'caption',
1685
- 'cell',
1686
- 'checkbox',
1687
- 'code',
1688
- 'columnheader',
1689
- 'combobox',
1690
- 'complementary',
1691
- 'contentinfo',
1692
- 'definition',
1693
- 'deletion',
1694
- 'dialog',
1695
- 'directory',
1696
- 'document',
1697
- 'emphasis',
1698
- 'feed',
1699
- 'figure',
1700
- 'form',
1701
- 'generic',
1702
- 'grid',
1703
- 'gridcell',
1704
- 'group',
1705
- 'heading',
1706
- 'img',
1707
- 'insertion',
1708
- 'link',
1709
- 'list',
1710
- 'listbox',
1711
- 'listitem',
1712
- 'log',
1713
- 'main',
1714
- 'marquee',
1715
- 'math',
1716
- 'meter',
1717
- 'menu',
1718
- 'menubar',
1719
- 'menuitem',
1720
- 'menuitemcheckbox',
1721
- 'menuitemradio',
1722
- 'navigation',
1723
- 'none',
1724
- 'note',
1725
- 'option',
1726
- 'paragraph',
1727
- 'presentation',
1728
- 'progressbar',
1729
- 'radio',
1730
- 'radiogroup',
1731
- 'region',
1732
- 'row',
1733
- 'rowgroup',
1734
- 'rowheader',
1735
- 'scrollbar',
1736
- 'search',
1737
- 'searchbox',
1738
- 'separator',
1739
- 'slider',
1740
- 'spinbutton',
1741
- 'status',
1742
- 'strong',
1743
- 'subscript',
1744
- 'superscript',
1745
- 'switch',
1746
- 'tab',
1747
- 'table',
1748
- 'tablist',
1749
- 'tabpanel',
1750
- 'term',
1751
- 'textbox',
1752
- 'time',
1753
- 'timer',
1754
- 'toolbar',
1755
- 'tooltip',
1756
- 'tree',
1757
- 'treegrid',
1758
- 'treeitem',
1759
- ]);
1760
- // ============================================================================
1761
- // Bounding Box (alias for BoundingBoxResult)
1762
- // ============================================================================
1763
- /**
1764
- * Bounding box (alias for PlaywrightBoundingBoxResult)
1765
- * @see https://playwright.dev/docs/api/class-locator#locator-bounding-box
1766
- */
1767
- export const PlaywrightBoundingBoxSchema = PlaywrightBoundingBoxResultSchema;
1768
- // ============================================================================
1769
- // Element State
1770
- // ============================================================================
1771
- /**
1772
- * Element state for waitFor
1773
- * @see https://playwright.dev/docs/api/class-locator#locator-wait-for
1774
- */
1775
- export const PlaywrightElementStateSchema = z.enum([
1776
- 'attached',
1777
- 'detached',
1778
- 'visible',
1779
- 'hidden',
1780
- ]);
1781
- // ============================================================================
1782
- // Event Init (for dispatchEvent)
1783
- // ============================================================================
1784
- /**
1785
- * Event initialization options for dispatchEvent
1786
- * @see https://playwright.dev/docs/api/class-locator#locator-dispatch-event
1787
- */
1788
- export const PlaywrightEventInitSchema = z.record(z.string(), z.unknown());
1789
- // ============================================================================
1790
- // Dispatch Event Options
1791
- // ============================================================================
1792
- /**
1793
- * Options for dispatchEvent() method
1794
- * @see https://playwright.dev/docs/api/class-locator#locator-dispatch-event
1795
- */
1796
- export const PlaywrightDispatchEventOptionsSchema = z.object({
1797
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
1798
- timeout: z.number().nonnegative().optional(),
1799
- });
1800
- // ============================================================================
1801
- // Timeout Options (generic)
1802
- // ============================================================================
1803
- /**
1804
- * Generic timeout options used by various methods
1805
- */
1806
- export const PlaywrightTimeoutOptionsSchema = z.object({
1807
- /** Maximum time in milliseconds. Defaults to 0 (no timeout). */
1808
- timeout: z.number().nonnegative().optional(),
1809
- });
1810
- // ============================================================================
1811
- // Select Option (alias for SelectOptionValue)
1812
- // ============================================================================
1813
- /**
1814
- * Select option value (alias for PlaywrightSelectOptionValue)
1815
- * @see https://playwright.dev/docs/api/class-locator#locator-select-option
1816
- */
1817
- export const PlaywrightSelectOptionSchema = PlaywrightSelectOptionValueSchema;
1818
- // ============================================================================
1819
- // Select Option Options (alias for SelectOptions)
1820
- // ============================================================================
1821
- /**
1822
- * Options for selectOption (alias for PlaywrightSelectOptions)
1823
- */
1824
- export const PlaywrightSelectOptionOptionsSchema = PlaywrightSelectOptionsSchema;
1825
- // ============================================================================
1826
- // Keyboard Options (alias for KeyboardPressOptions)
1827
- // ============================================================================
1828
- /**
1829
- * Keyboard options (alias for KeyboardPressOptions)
1830
- */
1831
- export const PlaywrightKeyboardOptionsSchema = PlaywrightKeyboardPressOptionsSchema;
1832
- // ============================================================================
1833
- // Clip Region (alias for ScreenshotClip)
1834
- // ============================================================================
1835
- /**
1836
- * Screenshot clip region (alias for PlaywrightScreenshotClip)
1837
- */
1838
- export const PlaywrightClipRegionSchema = PlaywrightScreenshotClipSchema;
1839
- // ============================================================================
1840
- // Page Screenshot Options (alias for ScreenshotOptions)
1841
- // ============================================================================
1842
- /**
1843
- * Page screenshot options (alias for PlaywrightScreenshotOptions)
1844
- */
1845
- export const PlaywrightPageScreenshotOptionsSchema = PlaywrightScreenshotOptionsSchema;
1846
- // ============================================================================
1847
- // New Page Options (alias for NewContextOptions)
1848
- // ============================================================================
1849
- /**
1850
- * Options for browser.newPage() - same as newContext options
1851
- * @see https://playwright.dev/docs/api/class-browser#browser-new-page
1852
- */
1853
- export const PlaywrightNewPageOptionsSchema = PlaywrightNewContextOptionsSchema;
1854
- // ============================================================================
1855
- // Additional Type Aliases (for generated code compatibility)
1856
- // ============================================================================
1857
- /**
1858
- * Filter options (alias for PlaywrightLocatorFilterOptions)
1859
- */
1860
- export const PlaywrightFilterOptionsSchema = PlaywrightLocatorFilterOptionsSchema;
1861
- /**
1862
- * Locator options (for page.locator() and locator.locator())
1863
- * Same as PlaywrightLocatorFilterOptions but used in the locator() method.
1864
- */
1865
- export const PlaywrightLocatorOptionsSchema = PlaywrightLocatorFilterOptionsSchema;
1866
- /**
1867
- * Get by test ID options (same as GetByText, just has exact option)
1868
- */
1869
- export const PlaywrightGetByTestIdOptionsSchema = z.object({
1870
- /** Exact match. Defaults to false. */
1871
- exact: z.boolean().optional(),
1872
- });
1873
- /**
1874
- * Scroll into view if needed options (alias for ScrollIntoViewOptions)
1875
- */
1876
- export const PlaywrightScrollIntoViewIfNeededOptionsSchema = PlaywrightScrollIntoViewOptionsSchema;
1877
- /**
1878
- * Drag and drop options (same as DragTo)
1879
- */
1880
- export const PlaywrightDragAndDropOptionsSchema = PlaywrightDragToOptionsSchema;
1881
- /**
1882
- * Set content options
1883
- * @see https://playwright.dev/docs/api/class-page#page-set-content
1884
- */
1885
- export const PlaywrightSetContentOptionsSchema = z.object({
1886
- /** Maximum time in milliseconds. */
1887
- timeout: z.number().nonnegative().optional(),
1888
- /** When to consider operation succeeded. */
1889
- waitUntil: PlaywrightWaitUntilSchema.optional(),
1890
- });
1891
- /**
1892
- * Viewport size (alias for Viewport)
1893
- */
1894
- export const PlaywrightViewportSizeSchema = PlaywrightViewportSchema;
1895
- /**
1896
- * Wait for function options
1897
- * @see https://playwright.dev/docs/api/class-page#page-wait-for-function
1898
- */
1899
- export const PlaywrightWaitForFunctionOptionsSchema = z.object({
1900
- /** Maximum time in milliseconds. */
1901
- timeout: z.number().nonnegative().optional(),
1902
- /** Polling interval in milliseconds or 'raf' for requestAnimationFrame. */
1903
- polling: z.union([z.number().positive(), z.literal('raf')]).optional(),
1904
- });
1905
- /**
1906
- * Wait until state (alias for WaitUntil)
1907
- */
1908
- export const WaitUntilStateSchema = PlaywrightWaitUntilSchema;
1909
- // Note: SelectOption is defined in sdk/base/types.ts and matches PlaywrightSelectOptionValue
1910
- // ============================================================================
1911
- // Page Events (for waitForEvent, on, once)
1912
- // ============================================================================
1913
- /**
1914
- * Page event name types (string enum for validation)
1915
- * @see https://playwright.dev/docs/api/class-page#events
1916
- */
1917
- export const PlaywrightPageEventNamesSchema = z.enum([
1918
- 'close',
1919
- 'console',
1920
- 'crash',
1921
- 'dialog',
1922
- 'domcontentloaded',
1923
- 'download',
1924
- 'filechooser',
1925
- 'frameattached',
1926
- 'framedetached',
1927
- 'framenavigated',
1928
- 'load',
1929
- 'pageerror',
1930
- 'popup',
1931
- 'request',
1932
- 'requestfailed',
1933
- 'requestfinished',
1934
- 'response',
1935
- 'websocket',
1936
- 'worker',
1937
- ]);
1938
- // ============================================================================
1939
- // Request/Response Types (serialized for RPC)
1940
- // ============================================================================
1941
- /**
1942
- * Serialized request for RPC
1943
- * @see https://playwright.dev/docs/api/class-request
1944
- */
1945
- export const PlaywrightRequestSchema = z.object({
1946
- url: z.string(),
1947
- method: z.string(),
1948
- headers: z.record(z.string(), z.string()).optional(),
1949
- postData: z.string().nullable().optional(),
1950
- resourceType: z.string().optional(),
1951
- isNavigationRequest: z.boolean().optional(),
1952
- redirectedFrom: z.string().nullable().optional(),
1953
- redirectedTo: z.string().nullable().optional(),
1954
- failure: z.string().nullable().optional(),
1955
- timing: z.object({
1956
- startTime: z.number(),
1957
- domainLookupStart: z.number(),
1958
- domainLookupEnd: z.number(),
1959
- connectStart: z.number(),
1960
- secureConnectionStart: z.number(),
1961
- connectEnd: z.number(),
1962
- requestStart: z.number(),
1963
- responseStart: z.number(),
1964
- responseEnd: z.number(),
1965
- }).optional(),
1966
- });
1967
- /**
1968
- * Serialized response for RPC
1969
- * @see https://playwright.dev/docs/api/class-response
1970
- */
1971
- export const PlaywrightResponseSchema = z.object({
1972
- url: z.string(),
1973
- status: z.number(),
1974
- statusText: z.string(),
1975
- headers: z.record(z.string(), z.string()),
1976
- ok: z.boolean(),
1977
- fromCache: z.boolean().optional(),
1978
- fromServiceWorker: z.boolean().optional(),
1979
- securityDetails: z.object({
1980
- issuer: z.string().optional(),
1981
- protocol: z.string().optional(),
1982
- subjectName: z.string().optional(),
1983
- validFrom: z.number().optional(),
1984
- validTo: z.number().optional(),
1985
- }).nullable().optional(),
1986
- });
1987
- // ============================================================================
1988
- // API Response Type (for APIRequestContext)
1989
- // ============================================================================
1990
- /**
1991
- * API response for APIRequestContext methods
1992
- * @see https://playwright.dev/docs/api/class-apiresponse
1993
- */
1994
- export const PlaywrightAPIResponseSchema = z.object({
1995
- /** Response URL */
1996
- url: z.string(),
1997
- /** HTTP status code */
1998
- status: z.number(),
1999
- /** HTTP status text */
2000
- statusText: z.string(),
2001
- /** Response headers */
2002
- headers: z.record(z.string(), z.string()),
2003
- /** Response headers as array of name-value pairs */
2004
- headersArray: z.array(z.object({
2005
- name: z.string(),
2006
- value: z.string(),
2007
- })),
2008
- /** Whether response was successful (status 200-299) */
2009
- ok: z.boolean(),
2010
- /** Response body as text */
2011
- text: z.string().optional(),
2012
- /** Response body as JSON (if parseable) */
2013
- json: z.unknown().optional(),
2014
- /** Response body as base64 (for binary) */
2015
- body: z.string().optional(),
2016
- });
2017
- // ============================================================================
2018
- // Console Message Type (for consoleMessages())
2019
- // ============================================================================
2020
- /**
2021
- * Serialized console message for RPC
2022
- * @see https://playwright.dev/docs/api/class-consolemessage
2023
- */
2024
- export const PlaywrightConsoleMessageSchema = z.object({
2025
- /** Message type (log, info, warn, error, etc.) */
2026
- type: PlaywrightConsoleMessageTypeSchema,
2027
- /** Message text */
2028
- text: z.string(),
2029
- /** Source location */
2030
- location: PlaywrightConsoleMessageLocationSchema.optional(),
2031
- /** Message arguments (serialized) */
2032
- args: z.array(z.unknown()).optional(),
2033
- });