1 package playwright 2 3 type BindingCall interface { 4 Call(f BindingCallFunction) 5 } 6 7 // A Browser is created via BrowserType.launch(). An example of using a `Browser` to create a `Page`: 8 type Browser interface { 9 EventEmitter 10 // In case this browser is obtained using BrowserType.launch(), closes the browser and all of its pages (if any 11 // were opened). 12 // In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the 13 // browser server. 14 // The `Browser` object itself is considered to be disposed and cannot be used anymore. 15 Close() error 16 // Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts. 17 Contexts() []BrowserContext 18 // Indicates that the browser is connected. 19 IsConnected() bool 20 // Creates a new browser context. It won't share cookies/cache with other browser contexts. 21 NewContext(options ...BrowserNewContextOptions) (BrowserContext, error) 22 // Creates a new page in a new browser context. Closing this page will close the context as well. 23 // This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and 24 // testing frameworks should explicitly create Browser.newContext() followed by the 25 // BrowserContext.newPage() to control their exact life times. 26 NewPage(options ...BrowserNewContextOptions) (Page, error) 27 // > NOTE: CDP Sessions are only supported on Chromium-based browsers. 28 // Returns the newly created browser session. 29 NewBrowserCDPSession() (CDPSession, error) 30 // Returns the browser version. 31 Version() string 32 } 33 34 // The `CDPSession` instances are used to talk raw Chrome Devtools Protocol: 35 // - protocol methods can be called with `session.send` method. 36 // - protocol events can be subscribed to with `session.on` method. 37 // Useful links: 38 // - Documentation on DevTools Protocol can be found here: 39 // [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/). 40 // - Getting Started with DevTools Protocol: 41 // https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md 42 type CDPSession interface { 43 EventEmitter 44 // Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to 45 // send messages. 46 Detach() error 47 Send(method string, params map[string]interface{}) (interface{}, error) 48 } 49 50 // BrowserContexts provide a way to operate multiple independent browser sessions. 51 // If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser 52 // context. 53 // Playwright allows creating "incognito" browser contexts with Browser.newContext() method. "Incognito" browser 54 // contexts don't write any browsing data to disk. 55 type BrowserContext interface { 56 EventEmitter 57 // Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be 58 // obtained via BrowserContext.cookies(). 59 AddCookies(cookies ...BrowserContextAddCookiesOptionsCookies) error 60 // Adds a script which would be evaluated in one of the following scenarios: 61 // - Whenever a page is created in the browser context or is navigated. 62 // - Whenever a child frame is attached or navigated in any page in the browser context. In this case, the script is 63 // evaluated in the context of the newly attached frame. 64 // The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend 65 // the JavaScript environment, e.g. to seed `Math.random`. 66 // An example of overriding `Math.random` before the page loads: 67 // > NOTE: The order of evaluation of multiple scripts installed via BrowserContext.addInitScript() and 68 // Page.addInitScript() is not defined. 69 AddInitScript(script BrowserContextAddInitScriptOptions) error 70 // Returns the browser instance of the context. If it was launched as a persistent context null gets returned. 71 Browser() Browser 72 // Clears context cookies. 73 ClearCookies() error 74 // Clears all permission overrides for the browser context. 75 ClearPermissions() error 76 // Closes the browser context. All the pages that belong to the browser context will be closed. 77 // > NOTE: The default browser context cannot be closed. 78 Close() error 79 // If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs 80 // are returned. 81 Cookies(urls ...string) ([]*BrowserContextCookiesResult, error) 82 ExpectEvent(event string, cb func() error) (interface{}, error) 83 // The method adds a function called `name` on the `window` object of every frame in every page in the context. When 84 // called, the function executes `callback` and returns a [Promise] which resolves to the return value of `callback`. If 85 // the `callback` returns a [Promise], it will be awaited. 86 // The first argument of the `callback` function contains information about the caller: `{ browserContext: BrowserContext, 87 // page: Page, frame: Frame }`. 88 // See Page.exposeBinding() for page-only version. 89 // An example of exposing page URL to all frames in all pages in the context: 90 // An example of passing an element handle: 91 ExposeBinding(name string, binding BindingCallFunction, handle ...bool) error 92 // The method adds a function called `name` on the `window` object of every frame in every page in the context. When 93 // called, the function executes `callback` and returns a [Promise] which resolves to the return value of `callback`. 94 // If the `callback` returns a [Promise], it will be awaited. 95 // See Page.exposeFunction() for page-only version. 96 // An example of adding a `sha256` function to all pages in the context: 97 ExposeFunction(name string, binding ExposedFunction) error 98 // Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if 99 // specified. 100 GrantPermissions(permissions []string, options ...BrowserContextGrantPermissionsOptions) error 101 // > NOTE: CDP sessions are only supported on Chromium-based browsers. 102 // Returns the newly created session. 103 NewCDPSession(page Page) (CDPSession, error) 104 // Creates a new page in the browser context. 105 NewPage(options ...BrowserNewPageOptions) (Page, error) 106 // Returns all open pages in the context. 107 Pages() []Page 108 // This setting will change the default maximum navigation time for the following methods and related shortcuts: 109 // - Page.goBack() 110 // - Page.goForward() 111 // - Page.goto() 112 // - Page.reload() 113 // - Page.setContent() 114 // - Page.waitForNavigation() 115 // > NOTE: Page.setDefaultNavigationTimeout`] and [`method: Page.setDefaultTimeout() take priority over 116 // BrowserContext.setDefaultNavigationTimeout(). 117 SetDefaultNavigationTimeout(timeout float64) 118 // This setting will change the default maximum time for all the methods accepting `timeout` option. 119 // > NOTE: Page.setDefaultNavigationTimeout`], [`method: Page.setDefaultTimeout() and 120 // BrowserContext.setDefaultNavigationTimeout`] take priority over [`method: BrowserContext.setDefaultTimeout(). 121 SetDefaultTimeout(timeout float64) 122 // The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged 123 // with page-specific extra HTTP headers set with Page.setExtraHTTPHeaders(). If page overrides a particular 124 // header, page-specific header value will be used instead of the browser context header value. 125 // > NOTE: BrowserContext.setExtraHTTPHeaders() does not guarantee the order of headers in the outgoing requests. 126 SetExtraHTTPHeaders(headers map[string]string) error 127 // Sets the context's geolocation. Passing `null` or `undefined` emulates position unavailable. 128 // > NOTE: Consider using BrowserContext.grantPermissions() to grant permissions for the browser context pages to 129 // read its geolocation. 130 SetGeolocation(gelocation *SetGeolocationOptions) error 131 ResetGeolocation() error 132 // Routing provides the capability to modify network requests that are made by any page in the browser context. Once route 133 // is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted. 134 // > NOTE: Page.route() will not intercept requests intercepted by Service Worker. See 135 // [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using 136 // request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);` 137 // An example of a naive handler that aborts all image requests: 138 // or the same snippet using a regex pattern instead: 139 // It is possible to examine the request to decide the route action. For example, mocking all requests that contain some 140 // post data, and leaving all other requests as is: 141 // Page routes (set up with Page.route()) take precedence over browser context routes when request matches both 142 // handlers. 143 // To remove a route with its handler you can use BrowserContext.unroute(). 144 // > NOTE: Enabling routing disables http cache. 145 Route(url interface{}, handler routeHandler) error 146 SetOffline(offline bool) error 147 // Returns storage state for this browser context, contains current cookies and local storage snapshot. 148 StorageState(path ...string) (*StorageState, error) 149 // Removes a route created with BrowserContext.route(). When `handler` is not specified, removes all routes for 150 // the `url`. 151 Unroute(url interface{}, handler ...routeHandler) error 152 // Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy 153 // value. Will throw an error if the context closes before the event is fired. Returns the event data value. 154 WaitForEvent(event string, predicate ...interface{}) interface{} 155 Tracing() Tracing 156 // > NOTE: Background pages are only supported on Chromium-based browsers. 157 // All existing background pages in the context. 158 BackgroundPages() []Page 159 } 160 161 // API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](./trace-viewer.md) 162 // after Playwright script runs. 163 // Start recording a trace before performing actions. At the end, stop tracing and save it to a file. 164 type Tracing interface { 165 // Start tracing. 166 Start(options ...TracingStartOptions) error 167 // Stop tracing. 168 Stop(options ...TracingStopOptions) error 169 // Start a new trace chunk. If you'd like to record multiple traces on the same `BrowserContext`, use 170 // Tracing.start`] once, and then create multiple trace chunks with [`method: Tracing.startChunk() and 171 // Tracing.stopChunk(). 172 StartChunk(options ...TracingStartChunkOptions) error 173 // Stop the trace chunk. See Tracing.startChunk() for more details about multiple trace chunks. 174 StopChunk(options ...TracingStopChunkOptions) error 175 } 176 177 // BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a 178 // typical example of using Playwright to drive automation: 179 type BrowserType interface { 180 // A path where Playwright expects to find a bundled browser executable. 181 ExecutablePath() string 182 // Returns the browser instance. 183 // You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments: 184 // > **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works 185 // best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use 186 // `executablePath` option with extreme caution. 187 // > 188 // > If Google Chrome (rather than Chromium) is preferred, a 189 // [Chrome Canary](https://www.google.com/chrome/browser/canary.html) or 190 // [Dev Channel](https://www.chromium.org/getting-involved/dev-channel) build is suggested. 191 // > 192 // > Stock browsers like Google Chrome and Microsoft Edge are suitable for tests that require proprietary media codecs for 193 // video playback. See 194 // [this article](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/) for other 195 // differences between Chromium and Chrome. 196 // [This article](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md) 197 // describes some differences for Linux users. 198 Launch(options ...BrowserTypeLaunchOptions) (Browser, error) 199 // Returns the persistent browser context instance. 200 // Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this 201 // context will automatically close the browser. 202 LaunchPersistentContext(userDataDir string, options ...BrowserTypeLaunchPersistentContextOptions) (BrowserContext, error) 203 // Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`. 204 Name() string 205 // This methods attaches Playwright to an existing browser instance. 206 Connect(url string, options ...BrowserTypeConnectOptions) (Browser, error) 207 // This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol. 208 // The default browser context is accessible via Browser.contexts(). 209 // > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers. 210 ConnectOverCDP(endpointURL string, options ...BrowserTypeConnectOverCDPOptions) (Browser, error) 211 } 212 213 // `ConsoleMessage` objects are dispatched by page via the [`event: Page.console`] event. 214 type ConsoleMessage interface { 215 // List of arguments passed to a `console` function call. See also [`event: Page.console`]. 216 Args() []JSHandle 217 Location() ConsoleMessageLocation 218 String() string 219 // The text of the console message. 220 Text() string 221 // One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`, 222 // `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`, `'profileEnd'`, 223 // `'count'`, `'timeEnd'`. 224 Type() string 225 } 226 227 // `Dialog` objects are dispatched by page via the [`event: Page.dialog`] event. 228 // An example of using `Dialog` class: 229 // > NOTE: Dialogs are dismissed automatically, unless there is a [`event: Page.dialog`] listener. When listener is 230 // present, it **must** either Dialog.accept`] or [`method: Dialog.dismiss() the dialog - otherwise the page will 231 // [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and 232 // actions like click will never finish. 233 type Dialog interface { 234 // Returns when the dialog has been accepted. 235 Accept(texts ...string) error 236 // If dialog is prompt, returns default prompt value. Otherwise, returns empty string. 237 DefaultValue() string 238 // Returns when the dialog has been dismissed. 239 Dismiss() error 240 // A message displayed in the dialog. 241 Message() string 242 // Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`. 243 Type() string 244 } 245 246 // `Download` objects are dispatched by page via the [`event: Page.download`] event. 247 // All the downloaded files belonging to the browser context are deleted when the browser context is closed. 248 // Download event is emitted once the download starts. Download path becomes available once download completes: 249 type Download interface { 250 // Deletes the downloaded file. Will wait for the download to finish if necessary. 251 Delete() error 252 // Returns download error if any. Will wait for the download to finish if necessary. 253 Failure() (string, error) 254 // Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if 255 // necessary. The method throws when connected remotely. 256 // Note that the download's file name is a random GUID, use Download.suggestedFilename() to get suggested file 257 // name. 258 Path() (string, error) 259 // Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will 260 // wait for the download to finish if necessary. 261 SaveAs(path string) error 262 String() string 263 // Returns suggested filename for this download. It is typically computed by the browser from the 264 // [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) response header 265 // or the `download` attribute. See the spec on [whatwg](https://html.spec.whatwg.org/#downloading-resources). Different 266 // browsers can use different logic for computing it. 267 SuggestedFilename() string 268 // Returns downloaded url. 269 URL() string 270 // Get the page that the download belongs to. 271 Page() Page 272 // Cancels a download. Will not fail if the download is already finished or canceled. Upon successful cancellations, 273 // `download.failure()` would resolve to `'canceled'`. 274 Cancel() error 275 } 276 277 // ElementHandle represents an in-page DOM element. ElementHandles can be created with the Page.querySelector() 278 // method. 279 // > NOTE: The use of ElementHandle is discouraged, use `Locator` objects and web-first assertions instead. 280 // ElementHandle prevents DOM element from garbage collection unless the handle is disposed with 281 // JSHandle.dispose(). ElementHandles are auto-disposed when their origin frame gets navigated. 282 // ElementHandle instances can be used as an argument in Page.evalOnSelector`] and [`method: Page.evaluate() 283 // methods. 284 // The difference between the `Locator` and ElementHandle is that the ElementHandle points to a particular element, while 285 // `Locator` captures the logic of how to retrieve an element. 286 // In the example below, handle points to a particular DOM element on page. If that element changes text or is used by 287 // React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to 288 // unexpected behaviors. 289 // With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So 290 // in the snippet below, underlying DOM element is going to be located twice. 291 type ElementHandle interface { 292 JSHandle 293 // This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is 294 // calculated relative to the main frame viewport - which is usually the same as the browser window. 295 // Scrolling affects the returned bonding box, similarly to 296 // [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That 297 // means `x` and/or `y` may be negative. 298 // Elements from child frames return the bounding box relative to the main frame, unlike the 299 // [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). 300 // Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following 301 // snippet should click the center of the element. 302 BoundingBox() (*Rect, error) 303 // This method checks the element by performing the following steps: 304 // 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, 305 // this method returns immediately. 306 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 307 // 1. Scroll the element into view if needed. 308 // 1. Use [`property: Page.mouse`] to click in the center of the element. 309 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 310 // 1. Ensure that the element is now checked. If not, this method throws. 311 // If the element is detached from the DOM at any moment during the action, this method throws. 312 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 313 // zero timeout disables this. 314 Check(options ...ElementHandleCheckOptions) error 315 // This method checks or unchecks an element by performing the following steps: 316 // 1. Ensure that element is a checkbox or a radio input. If not, this method throws. 317 // 1. If the element already has the right checked state, this method returns immediately. 318 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 319 // element is detached during the checks, the whole action is retried. 320 // 1. Scroll the element into view if needed. 321 // 1. Use [`property: Page.mouse`] to click in the center of the element. 322 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 323 // 1. Ensure that the element is now checked or unchecked. If not, this method throws. 324 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 325 // zero timeout disables this. 326 SetChecked(checked bool, options ...ElementHandleSetCheckedOptions) error 327 // This method clicks the element by performing the following steps: 328 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 329 // 1. Scroll the element into view if needed. 330 // 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`. 331 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 332 // If the element is detached from the DOM at any moment during the action, this method throws. 333 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 334 // zero timeout disables this. 335 Click(options ...ElementHandleClickOptions) error 336 // Returns the content frame for element handles referencing iframe nodes, or `null` otherwise 337 ContentFrame() (Frame, error) 338 // This method double clicks the element by performing the following steps: 339 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 340 // 1. Scroll the element into view if needed. 341 // 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`. 342 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the 343 // first click of the `dblclick()` triggers a navigation event, this method will throw. 344 // If the element is detached from the DOM at any moment during the action, this method throws. 345 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 346 // zero timeout disables this. 347 // > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event. 348 Dblclick(options ...ElementHandleDblclickOptions) error 349 // The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, 350 // `click` is dispatched. This is equivalent to calling 351 // [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click). 352 // Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties 353 // and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default. 354 // Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties: 355 // - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent) 356 // - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent) 357 // - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent) 358 // - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent) 359 // - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent) 360 // - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent) 361 // - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event) 362 // You can also specify `JSHandle` as the property value if you want live objects to be passed into the event: 363 DispatchEvent(typ string, initObjects ...interface{}) error 364 // Returns the return value of `expression`. 365 // The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first 366 // argument to `expression`. See [Working with selectors](./selectors.md) for more details. If no elements match the 367 // selector, the method throws an error. 368 // If `expression` returns a [Promise], then ElementHandle.evalOnSelector() would wait for the promise to resolve 369 // and return its value. 370 // Examples: 371 EvalOnSelector(selector string, expression string, options ...interface{}) (interface{}, error) 372 // Returns the return value of `expression`. 373 // The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of 374 // matched elements as a first argument to `expression`. See [Working with selectors](./selectors.md) for more details. 375 // If `expression` returns a [Promise], then ElementHandle.evalOnSelectorAll() would wait for the promise to 376 // resolve and return its value. 377 // Examples: 378 // ```html 379 // <div class="feed"> 380 // <div class="tweet">Hello!</div> 381 // <div class="tweet">Hi!</div> 382 // </div> 383 // ``` 384 EvalOnSelectorAll(selector string, expression string, options ...interface{}) (interface{}, error) 385 // This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` 386 // event after filling. Note that you can pass an empty string to clear the input field. 387 // If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. 388 // However, if the element is inside the `<label>` element that has an associated 389 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled 390 // instead. 391 // To send fine-grained keyboard events, use ElementHandle.type(). 392 Fill(value string, options ...ElementHandleFillOptions) error 393 // Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element. 394 Focus() error 395 // Returns element attribute value. 396 GetAttribute(name string) (string, error) 397 // This method hovers over the element by performing the following steps: 398 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 399 // 1. Scroll the element into view if needed. 400 // 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`. 401 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 402 // If the element is detached from the DOM at any moment during the action, this method throws. 403 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 404 // zero timeout disables this. 405 Hover(options ...ElementHandleHoverOptions) error 406 // Returns the `element.innerHTML`. 407 InnerHTML() (string, error) 408 // Returns the `element.innerText`. 409 InnerText() (string, error) 410 // Returns whether the element is checked. Throws if the element is not a checkbox or radio input. 411 IsChecked() (bool, error) 412 // Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled). 413 IsDisabled() (bool, error) 414 // Returns whether the element is [editable](./actionability.md#editable). 415 IsEditable() (bool, error) 416 // Returns whether the element is [enabled](./actionability.md#enabled). 417 IsEnabled() (bool, error) 418 // Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). 419 IsHidden() (bool, error) 420 // Returns whether the element is [visible](./actionability.md#visible). 421 IsVisible() (bool, error) 422 // Returns the frame containing the given element. 423 OwnerFrame() (Frame, error) 424 // Focuses the element, and then uses Keyboard.down`] and [`method: Keyboard.up(). 425 // `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) 426 // value or a single character to generate the text for. A superset of the `key` values can be found 427 // [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are: 428 // `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, 429 // `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc. 430 // Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. 431 // Holding down `Shift` will type the text that corresponds to the `key` in the upper case. 432 // If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective 433 // texts. 434 // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the 435 // modifier, modifier is pressed and being held while the subsequent key is being pressed. 436 Press(key string, options ...ElementHandlePressOptions) error 437 // The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See 438 // [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns `null`. 439 QuerySelector(selector string) (ElementHandle, error) 440 // The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See 441 // [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns empty array. 442 QuerySelectorAll(selector string) ([]ElementHandle, error) 443 // Returns the buffer with the captured screenshot. 444 // This method waits for the [actionability](./actionability.md) checks, then scrolls element into view before taking a 445 // screenshot. If the element is detached from DOM, the method throws an error. 446 Screenshot(options ...ElementHandleScreenshotOptions) ([]byte, error) 447 // This method waits for [actionability](./actionability.md) checks, then tries to scroll element into view, unless it is 448 // completely visible as defined by 449 // [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`. 450 // Throws when `elementHandle` does not point to an element 451 // [connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot. 452 ScrollIntoViewIfNeeded(options ...ElementHandleScrollIntoViewIfNeededOptions) error 453 // This method waits for [actionability](./actionability.md) checks, waits until all specified options are present in the 454 // `<select>` element and selects these options. 455 // If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the 456 // `<label>` element that has an associated 457 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead. 458 // Returns the array of option values that have been successfully selected. 459 // Triggers a `change` and `input` event once all the provided options have been selected. 460 SelectOption(values SelectOptionValues, options ...ElementHandleSelectOptionOptions) ([]string, error) 461 // This method waits for [actionability](./actionability.md) checks, then focuses the element and selects all its text 462 // content. 463 SelectText(options ...ElementHandleSelectTextOptions) error 464 // This method expects `elementHandle` to point to an 465 // [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). 466 // Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they 467 // are resolved relative to the the current working directory. For empty array, clears the selected files. 468 SetInputFiles(files []InputFile, options ...ElementHandleSetInputFilesOptions) error 469 // This method taps the element by performing the following steps: 470 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 471 // 1. Scroll the element into view if needed. 472 // 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`. 473 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 474 // If the element is detached from the DOM at any moment during the action, this method throws. 475 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 476 // zero timeout disables this. 477 // > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true. 478 Tap(options ...ElementHandleTapOptions) error 479 // Returns the `node.textContent`. 480 TextContent() (string, error) 481 // Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. 482 // To press a special key, like `Control` or `ArrowDown`, use ElementHandle.press(). 483 // An example of typing into a text field and then submitting the form: 484 Type(value string, options ...ElementHandleTypeOptions) error 485 // This method checks the element by performing the following steps: 486 // 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already 487 // unchecked, this method returns immediately. 488 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 489 // 1. Scroll the element into view if needed. 490 // 1. Use [`property: Page.mouse`] to click in the center of the element. 491 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 492 // 1. Ensure that the element is now unchecked. If not, this method throws. 493 // If the element is detached from the DOM at any moment during the action, this method throws. 494 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 495 // zero timeout disables this. 496 Uncheck(options ...ElementHandleUncheckOptions) error 497 // Returns when the element satisfies the `state`. 498 // Depending on the `state` parameter, this method waits for one of the [actionability](./actionability.md) checks to pass. 499 // This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state. 500 // - `"visible"` Wait until the element is [visible](./actionability.md#visible). 501 // - `"hidden"` Wait until the element is [not visible](./actionability.md#visible) or 502 // [not attached](./actionability.md#attached). Note that waiting for hidden does not throw when the element detaches. 503 // - `"stable"` Wait until the element is both [visible](./actionability.md#visible) and 504 // [stable](./actionability.md#stable). 505 // - `"enabled"` Wait until the element is [enabled](./actionability.md#enabled). 506 // - `"disabled"` Wait until the element is [not enabled](./actionability.md#enabled). 507 // - `"editable"` Wait until the element is [editable](./actionability.md#editable). 508 // If the element does not satisfy the condition for the `timeout` milliseconds, this method will throw. 509 WaitForElementState(state string, options ...ElementHandleWaitForElementStateOptions) error 510 // Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or 511 // `detached`. 512 // Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or 513 // become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method 514 // will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will 515 // throw. 516 // > NOTE: This method does not work across navigations, use Page.waitForSelector() instead. 517 WaitForSelector(selector string, options ...ElementHandleWaitForSelectorOptions) (ElementHandle, error) 518 // Returns `input.value` for `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements. 519 InputValue(options ...ElementHandleInputValueOptions) (string, error) 520 } 521 522 type EventEmitter interface { 523 Emit(name string, payload ...interface{}) 524 ListenerCount(name string) int 525 On(name string, handler interface{}) 526 Once(name string, handler interface{}) 527 RemoveListener(name string, handler interface{}) 528 } 529 530 // `FileChooser` objects are dispatched by the page in the [`event: Page.fileChooser`] event. 531 type FileChooser interface { 532 // Returns input element associated with this file chooser. 533 Element() ElementHandle 534 // Returns whether this file chooser accepts multiple files. 535 IsMultiple() bool 536 // Returns page this file chooser belongs to. 537 Page() Page 538 // Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then 539 // they are resolved relative to the the current working directory. For empty array, clears the selected files. 540 SetFiles(files []InputFile, options ...ElementHandleSetInputFilesOptions) error 541 } 542 543 // At every point of time, page exposes its current frame tree via the Page.mainFrame() and 544 // Frame.childFrames() methods. 545 // `Frame` object's lifecycle is controlled by three events, dispatched on the page object: 546 // - [`event: Page.frameAttached`] - fired when the frame gets attached to the page. A Frame can be attached to the page 547 // only once. 548 // - [`event: Page.frameNavigated`] - fired when the frame commits navigation to a different URL. 549 // - [`event: Page.frameDetached`] - fired when the frame gets detached from the page. A Frame can be detached from the 550 // page only once. 551 // An example of dumping frame tree: 552 type Frame interface { 553 // This method checks or unchecks an element matching `selector` by performing the following steps: 554 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 555 // 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. 556 // 1. If the element already has the right checked state, this method returns immediately. 557 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 558 // element is detached during the checks, the whole action is retried. 559 // 1. Scroll the element into view if needed. 560 // 1. Use [`property: Page.mouse`] to click in the center of the element. 561 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 562 // 1. Ensure that the element is now checked or unchecked. If not, this method throws. 563 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 564 // zero timeout disables this. 565 SetChecked(selector string, checked bool, options ...FrameSetCheckedOptions) error 566 // Returns the added tag when the script's onload fires or when the script content was injected into frame. 567 // Adds a `<script>` tag into the page with the desired url or content. 568 AddScriptTag(options PageAddScriptTagOptions) (ElementHandle, error) 569 // Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame. 570 // Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the 571 // content. 572 AddStyleTag(options PageAddStyleTagOptions) (ElementHandle, error) 573 // This method checks an element matching `selector` by performing the following steps: 574 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 575 // 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already 576 // checked, this method returns immediately. 577 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 578 // element is detached during the checks, the whole action is retried. 579 // 1. Scroll the element into view if needed. 580 // 1. Use [`property: Page.mouse`] to click in the center of the element. 581 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 582 // 1. Ensure that the element is now checked. If not, this method throws. 583 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 584 // zero timeout disables this. 585 Check(selector string, options ...FrameCheckOptions) error 586 ChildFrames() []Frame 587 // This method clicks an element matching `selector` by performing the following steps: 588 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 589 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 590 // element is detached during the checks, the whole action is retried. 591 // 1. Scroll the element into view if needed. 592 // 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`. 593 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 594 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 595 // zero timeout disables this. 596 Click(selector string, options ...PageClickOptions) error 597 // Gets the full HTML contents of the frame, including the doctype. 598 Content() (string, error) 599 // This method double clicks an element matching `selector` by performing the following steps: 600 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 601 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 602 // element is detached during the checks, the whole action is retried. 603 // 1. Scroll the element into view if needed. 604 // 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`. 605 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the 606 // first click of the `dblclick()` triggers a navigation event, this method will throw. 607 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 608 // zero timeout disables this. 609 // > NOTE: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event. 610 Dblclick(selector string, options ...FrameDblclickOptions) error 611 // The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, 612 // `click` is dispatched. This is equivalent to calling 613 // [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click). 614 // Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties 615 // and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default. 616 // Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties: 617 // - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent) 618 // - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent) 619 // - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent) 620 // - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent) 621 // - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent) 622 // - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent) 623 // - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event) 624 // You can also specify `JSHandle` as the property value if you want live objects to be passed into the event: 625 DispatchEvent(selector, typ string, eventInit interface{}, options ...PageDispatchEventOptions) error 626 // Returns the return value of `expression`. 627 // If the function passed to the Frame.evaluate`] returns a [Promise], then [`method: Frame.evaluate() would wait 628 // for the promise to resolve and return its value. 629 // If the function passed to the Frame.evaluate() returns a non-[Serializable] value, then 630 // Frame.evaluate() returns `undefined`. Playwright also supports transferring some additional values that are 631 // not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`. 632 // A string can also be passed in instead of a function. 633 // `ElementHandle` instances can be passed as an argument to the Frame.evaluate(): 634 Evaluate(expression string, options ...interface{}) (interface{}, error) 635 // Returns the return value of `expression` as a `JSHandle`. 636 // The only difference between Frame.evaluate`] and [`method: Frame.evaluateHandle() is that 637 // Frame.evaluateHandle() returns `JSHandle`. 638 // If the function, passed to the Frame.evaluateHandle(), returns a [Promise], then 639 // Frame.evaluateHandle() would wait for the promise to resolve and return its value. 640 // A string can also be passed in instead of a function. 641 // `JSHandle` instances can be passed as an argument to the Frame.evaluateHandle(): 642 EvaluateHandle(expression string, options ...interface{}) (JSHandle, error) 643 // Returns the return value of `expression`. 644 // > NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky 645 // tests. Use Locator.evaluate(), other `Locator` helper methods or web-first assertions instead. 646 // The method finds an element matching the specified selector within the frame and passes it as a first argument to 647 // `expression`. See [Working with selectors](./selectors.md) for more details. If no elements match the selector, the 648 // method throws an error. 649 // If `expression` returns a [Promise], then Frame.evalOnSelector() would wait for the promise to resolve and 650 // return its value. 651 // Examples: 652 EvalOnSelector(selector string, expression string, options ...interface{}) (interface{}, error) 653 // Returns the return value of `expression`. 654 // > NOTE: In most cases, Locator.evaluateAll(), other `Locator` helper methods and web-first assertions do a 655 // better job. 656 // The method finds all elements matching the specified selector within the frame and passes an array of matched elements 657 // as a first argument to `expression`. See [Working with selectors](./selectors.md) for more details. 658 // If `expression` returns a [Promise], then Frame.evalOnSelectorAll() would wait for the promise to resolve and 659 // return its value. 660 // Examples: 661 EvalOnSelectorAll(selector string, expression string, options ...interface{}) (interface{}, error) 662 // This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the 663 // element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input 664 // field. 665 // If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. 666 // However, if the element is inside the `<label>` element that has an associated 667 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled 668 // instead. 669 // To send fine-grained keyboard events, use Frame.type(). 670 Fill(selector string, value string, options ...FrameFillOptions) error 671 // This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method 672 // waits until a matching element appears in the DOM. 673 Focus(selector string, options ...FrameFocusOptions) error 674 // Returns the `frame` or `iframe` element handle which corresponds to this frame. 675 // This is an inverse of ElementHandle.contentFrame(). Note that returned handle actually belongs to the parent 676 // frame. 677 // This method throws an error if the frame has been detached before `frameElement()` returns. 678 FrameElement() (ElementHandle, error) 679 // Returns element attribute value. 680 GetAttribute(selector string, name string, options ...PageGetAttributeOptions) (string, error) 681 // Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the 682 // last redirect. 683 // The method will throw an error if: 684 // - there's an SSL error (e.g. in case of self-signed certificates). 685 // - target URL is invalid. 686 // - the `timeout` is exceeded during navigation. 687 // - the remote server does not respond or is unreachable. 688 // - the main resource failed to load. 689 // The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not 690 // Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling 691 // Response.status(). 692 // > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to 693 // `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`. 694 // > NOTE: Headless mode doesn't support navigation to a PDF document. See the 695 // [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295). 696 Goto(url string, options ...PageGotoOptions) (Response, error) 697 // This method hovers over an element matching `selector` by performing the following steps: 698 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 699 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 700 // element is detached during the checks, the whole action is retried. 701 // 1. Scroll the element into view if needed. 702 // 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`. 703 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 704 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 705 // zero timeout disables this. 706 Hover(selector string, options ...PageHoverOptions) error 707 // Returns `element.innerHTML`. 708 InnerHTML(selector string, options ...PageInnerHTMLOptions) (string, error) 709 // Returns `element.innerText`. 710 InnerText(selector string, options ...PageInnerTextOptions) (string, error) 711 // Returns `true` if the frame has been detached, or `false` otherwise. 712 IsDetached() bool 713 // Returns whether the element is checked. Throws if the element is not a checkbox or radio input. 714 IsChecked(selector string, options ...FrameIsCheckedOptions) (bool, error) 715 // Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled). 716 IsDisabled(selector string, options ...FrameIsDisabledOptions) (bool, error) 717 // Returns whether the element is [editable](./actionability.md#editable). 718 IsEditable(selector string, options ...FrameIsEditableOptions) (bool, error) 719 // Returns whether the element is [enabled](./actionability.md#enabled). 720 IsEnabled(selector string, options ...FrameIsEnabledOptions) (bool, error) 721 // Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). `selector` that does not 722 // match any elements is considered hidden. 723 IsHidden(selector string, options ...FrameIsHiddenOptions) (bool, error) 724 // Returns whether the element is [visible](./actionability.md#visible). `selector` that does not match any elements is 725 // considered not visible. 726 IsVisible(selector string, options ...FrameIsVisibleOptions) (bool, error) 727 // The method returns an element locator that can be used to perform actions in the frame. Locator is resolved to the 728 // element immediately before performing an action, so a series of actions on the same locator can in fact be performed on 729 // different DOM elements. That would happen if the DOM structure between those actions has changed. 730 Locator(selector string, options ...FrameLocatorOptions) (Locator, error) 731 // Returns frame's name attribute as specified in the tag. 732 // If the name is empty, returns the id attribute instead. 733 // > NOTE: This value is calculated once when the frame is created, and will not update if the attribute is changed later. 734 Name() string 735 // Returns the page containing this frame. 736 Page() Page 737 // Parent frame, if any. Detached frames and main frames return `null`. 738 ParentFrame() Frame 739 // `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) 740 // value or a single character to generate the text for. A superset of the `key` values can be found 741 // [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are: 742 // `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, 743 // `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc. 744 // Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. 745 // Holding down `Shift` will type the text that corresponds to the `key` in the upper case. 746 // If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective 747 // texts. 748 // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the 749 // modifier, modifier is pressed and being held while the subsequent key is being pressed. 750 Press(selector, key string, options ...PagePressOptions) error 751 // Returns the ElementHandle pointing to the frame element. 752 // > NOTE: The use of `ElementHandle` is discouraged, use `Locator` objects and web-first assertions instead. 753 // The method finds an element matching the specified selector within the frame. See 754 // [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns `null`. 755 QuerySelector(selector string) (ElementHandle, error) 756 // Returns the ElementHandles pointing to the frame elements. 757 // > NOTE: The use of `ElementHandle` is discouraged, use `Locator` objects instead. 758 // The method finds all elements matching the specified selector within the frame. See 759 // [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns empty array. 760 QuerySelectorAll(selector string) ([]ElementHandle, error) 761 SetContent(content string, options ...PageSetContentOptions) error 762 // This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, waits until 763 // all specified options are present in the `<select>` element and selects these options. 764 // If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the 765 // `<label>` element that has an associated 766 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead. 767 // Returns the array of option values that have been successfully selected. 768 // Triggers a `change` and `input` event once all the provided options have been selected. 769 SelectOption(selector string, values SelectOptionValues, options ...FrameSelectOptionOptions) ([]string, error) 770 // This method expects `selector` to point to an 771 // [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). 772 // Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they 773 // are resolved relative to the the current working directory. For empty array, clears the selected files. 774 SetInputFiles(selector string, files []InputFile, options ...FrameSetInputFilesOptions) error 775 // This method taps an element matching `selector` by performing the following steps: 776 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 777 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 778 // element is detached during the checks, the whole action is retried. 779 // 1. Scroll the element into view if needed. 780 // 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`. 781 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 782 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 783 // zero timeout disables this. 784 // > NOTE: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true. 785 Tap(selector string, options ...FrameTapOptions) error 786 // Returns `element.textContent`. 787 TextContent(selector string, options ...FrameTextContentOptions) (string, error) 788 // Returns the page title. 789 Title() (string, error) 790 // Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to 791 // send fine-grained keyboard events. To fill values in form fields, use Frame.fill(). 792 // To press a special key, like `Control` or `ArrowDown`, use Keyboard.press(). 793 Type(selector, text string, options ...PageTypeOptions) error 794 // Returns frame's url. 795 URL() string 796 // This method checks an element matching `selector` by performing the following steps: 797 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 798 // 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already 799 // unchecked, this method returns immediately. 800 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 801 // element is detached during the checks, the whole action is retried. 802 // 1. Scroll the element into view if needed. 803 // 1. Use [`property: Page.mouse`] to click in the center of the element. 804 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 805 // 1. Ensure that the element is now unchecked. If not, this method throws. 806 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 807 // zero timeout disables this. 808 Uncheck(selector string, options ...FrameUncheckOptions) error 809 WaitForEvent(event string, predicate ...interface{}) interface{} 810 // Returns when the `expression` returns a truthy value, returns that value. 811 // The Frame.waitForFunction() can be used to observe viewport size change: 812 // To pass an argument to the predicate of `frame.waitForFunction` function: 813 WaitForFunction(expression string, arg interface{}, options ...FrameWaitForFunctionOptions) (JSHandle, error) 814 // Waits for the required load state to be reached. 815 // This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed 816 // when this method is called. If current document has already reached the required state, resolves immediately. 817 WaitForLoadState(given ...string) 818 // Waits for the frame navigation and returns the main resource response. In case of multiple redirects, the navigation 819 // will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to 820 // History API usage, the navigation will resolve with `null`. 821 // This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause 822 // the frame to navigate. Consider this example: 823 // > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is 824 // considered a navigation. 825 WaitForNavigation(options ...PageWaitForNavigationOptions) (Response, error) 826 // Waits for the frame to navigate to the given URL. 827 WaitForURL(url string, options ...FrameWaitForURLOptions) error 828 // Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or 829 // `detached`. 830 // > NOTE: Playwright automatically waits for element to be ready before performing an action. Using `Locator` objects and 831 // web-first assertions make the code wait-for-selector-free. 832 // Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at 833 // the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the 834 // selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw. 835 // This method works across navigations: 836 WaitForSelector(selector string, options ...PageWaitForSelectorOptions) (ElementHandle, error) 837 // Waits for the given `timeout` in milliseconds. 838 // Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to 839 // be flaky. Use signals such as network events, selectors becoming visible and others instead. 840 WaitForTimeout(timeout float64) 841 // Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements. 842 InputValue(selector string, options ...FrameInputValueOptions) (string, error) 843 DragAndDrop(source, target string, options ...FrameDragAndDropOptions) error 844 } 845 846 // JSHandle represents an in-page JavaScript object. JSHandles can be created with the Page.evaluateHandle() 847 // method. 848 // JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with 849 // JSHandle.dispose(). JSHandles are auto-disposed when their origin frame gets navigated or the parent context 850 // gets destroyed. 851 // JSHandle instances can be used as an argument in Page.evalOnSelector`], [`method: Page.evaluate() and 852 // Page.evaluateHandle() methods. 853 type JSHandle interface { 854 // Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. 855 AsElement() ElementHandle 856 // The `jsHandle.dispose` method stops referencing the element handle. 857 Dispose() error 858 // Returns the return value of `expression`. 859 // This method passes this handle as the first argument to `expression`. 860 // If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its value. 861 // Examples: 862 Evaluate(expression string, options ...interface{}) (interface{}, error) 863 // Returns the return value of `expression` as a `JSHandle`. 864 // This method passes this handle as the first argument to `expression`. 865 // The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns 866 // `JSHandle`. 867 // If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait 868 // for the promise to resolve and return its value. 869 // See Page.evaluateHandle() for more details. 870 EvaluateHandle(expression string, options ...interface{}) (JSHandle, error) 871 // The method returns a map with **own property names** as keys and JSHandle instances for the property values. 872 GetProperties() (map[string]JSHandle, error) 873 // Fetches a single property from the referenced object. 874 GetProperty(name string) (JSHandle, error) 875 // Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**. 876 // > NOTE: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an 877 // error if the object has circular references. 878 JSONValue() (interface{}, error) 879 String() string 880 } 881 882 // Keyboard provides an api for managing a virtual keyboard. The high level api is Keyboard.type(), which takes 883 // raw characters and generates proper keydown, keypress/input, and keyup events on your page. 884 // For finer control, you can use Keyboard.down`], [`method: Keyboard.up`], and [`method: Keyboard.insertText() 885 // to manually fire events as if they were generated from a real keyboard. 886 // An example of holding down `Shift` in order to select and delete some text: 887 // An example of pressing uppercase `A` 888 // An example to trigger select-all with the keyboard 889 type Keyboard interface { 890 // Dispatches a `keydown` event. 891 // `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) 892 // value or a single character to generate the text for. A superset of the `key` values can be found 893 // [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are: 894 // `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, 895 // `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc. 896 // Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. 897 // Holding down `Shift` will type the text that corresponds to the `key` in the upper case. 898 // If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective 899 // texts. 900 // If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier 901 // active. To release the modifier key, use Keyboard.up(). 902 // After the key is pressed once, subsequent calls to Keyboard.down() will have 903 // [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use 904 // Keyboard.up(). 905 // > NOTE: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case. 906 Down(key string) error 907 // Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events. 908 // > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case. 909 InsertText(text string) error 910 // `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) 911 // value or a single character to generate the text for. A superset of the `key` values can be found 912 // [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are: 913 // `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, 914 // `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc. 915 // Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. 916 // Holding down `Shift` will type the text that corresponds to the `key` in the upper case. 917 // If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective 918 // texts. 919 // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the 920 // modifier, modifier is pressed and being held while the subsequent key is being pressed. 921 // Shortcut for Keyboard.down`] and [`method: Keyboard.up(). 922 Press(key string, options ...KeyboardPressOptions) error 923 // Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. 924 // To press a special key, like `Control` or `ArrowDown`, use Keyboard.press(). 925 // > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case. 926 // > NOTE: For characters that are not on a US keyboard, only an `input` event will be sent. 927 Type(text string, options ...KeyboardTypeOptions) error 928 // Dispatches a `keyup` event. 929 Up(key string) error 930 } 931 932 // Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way 933 // to find element(s) on the page at any moment. Locator can be created with the Page.locator() method. 934 // [Learn more about locators](./locators.md). 935 type Locator interface { 936 // Returns an array of `node.innerText` values for all matching nodes. 937 AllInnerTexts() ([]string, error) 938 // Returns an array of `node.textContent` values for all matching nodes. 939 AllTextContents() ([]string, error) 940 // This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is 941 // calculated relative to the main frame viewport - which is usually the same as the browser window. 942 // Scrolling affects the returned bonding box, similarly to 943 // [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That 944 // means `x` and/or `y` may be negative. 945 // Elements from child frames return the bounding box relative to the main frame, unlike the 946 // [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). 947 // Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following 948 // snippet should click the center of the element. 949 BoundingBox(options ...LocatorBoundingBoxOptions) (*Rect, error) 950 // This method checks the element by performing the following steps: 951 // 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, 952 // this method returns immediately. 953 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 954 // 1. Scroll the element into view if needed. 955 // 1. Use [`property: Page.mouse`] to click in the center of the element. 956 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 957 // 1. Ensure that the element is now checked. If not, this method throws. 958 // If the element is detached from the DOM at any moment during the action, this method throws. 959 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 960 // zero timeout disables this. 961 Check(options ...FrameCheckOptions) error 962 // This method clicks the element by performing the following steps: 963 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 964 // 1. Scroll the element into view if needed. 965 // 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`. 966 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 967 // If the element is detached from the DOM at any moment during the action, this method throws. 968 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 969 // zero timeout disables this. 970 Click(options ...PageClickOptions) error 971 // Returns the number of elements matching given selector. 972 Count() (int, error) 973 // This method double clicks the element by performing the following steps: 974 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 975 // 1. Scroll the element into view if needed. 976 // 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`. 977 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the 978 // first click of the `dblclick()` triggers a navigation event, this method will throw. 979 // If the element is detached from the DOM at any moment during the action, this method throws. 980 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 981 // zero timeout disables this. 982 // > NOTE: `element.dblclick()` dispatches two `click` events and a single `dblclick` event. 983 Dblclick(options ...FrameDblclickOptions) error 984 // The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, 985 // `click` is dispatched. This is equivalent to calling 986 // [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click). 987 // Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties 988 // and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default. 989 // Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties: 990 // - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent) 991 // - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent) 992 // - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent) 993 // - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent) 994 // - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent) 995 // - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent) 996 // - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event) 997 // You can also specify `JSHandle` as the property value if you want live objects to be passed into the event: 998 DispatchEvent(typ string, eventInit interface{}, options ...PageDispatchEventOptions) error 999 DragTo(target Locator, options ...FrameDragAndDropOptions) error 1000 // Resolves given locator to the first matching DOM element. If no elements matching the query are visible, waits for them 1001 // up to a given timeout. If multiple elements match the selector, throws. 1002 ElementHandle(options ...LocatorElementHandleOptions) (ElementHandle, error) 1003 // Resolves given locator to all matching DOM elements. 1004 ElementHandles() ([]ElementHandle, error) 1005 // Returns the return value of `expression`. 1006 // This method passes this handle as the first argument to `expression`. 1007 // If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its value. 1008 // Examples: 1009 Evaluate(expression string, arg interface{}, options ...LocatorEvaluateOptions) (interface{}, error) 1010 // The method finds all elements matching the specified locator and passes an array of matched elements as a first argument 1011 // to `expression`. Returns the result of `expression` invocation. 1012 // If `expression` returns a [Promise], then Locator.evaluateAll() would wait for the promise to resolve and 1013 // return its value. 1014 // Examples: 1015 EvaluateAll(expression string, options ...interface{}) (interface{}, error) 1016 // Returns the return value of `expression` as a `JSHandle`. 1017 // This method passes this handle as the first argument to `expression`. 1018 // The only difference between Locator.evaluate`] and [`method: Locator.evaluateHandle() is that 1019 // Locator.evaluateHandle() returns `JSHandle`. 1020 // If the function passed to the Locator.evaluateHandle() returns a [Promise], then 1021 // Locator.evaluateHandle() would wait for the promise to resolve and return its value. 1022 // See Page.evaluateHandle() for more details. 1023 EvaluateHandle(expression string, arg interface{}, options ...LocatorEvaluateHandleOptions) (interface{}, error) 1024 // This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` 1025 // event after filling. Note that you can pass an empty string to clear the input field. 1026 // If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. 1027 // However, if the element is inside the `<label>` element that has an associated 1028 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled 1029 // instead. 1030 // To send fine-grained keyboard events, use Locator.type(). 1031 Fill(value string, options ...FrameFillOptions) error 1032 // Returns locator to the first matching element. 1033 First() (Locator, error) 1034 // Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element. 1035 Focus(options ...FrameFocusOptions) error 1036 // Returns element attribute value. 1037 GetAttribute(name string, options ...PageGetAttributeOptions) (string, error) 1038 // Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses 1039 // Locator.highlight(). 1040 Highlight() error 1041 // This method hovers over the element by performing the following steps: 1042 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 1043 // 1. Scroll the element into view if needed. 1044 // 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`. 1045 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1046 // If the element is detached from the DOM at any moment during the action, this method throws. 1047 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1048 // zero timeout disables this. 1049 Hover(options ...PageHoverOptions) error 1050 // Returns the `element.innerHTML`. 1051 InnerHTML(options ...PageInnerHTMLOptions) (string, error) 1052 // Returns the `element.innerText`. 1053 InnerText(options ...PageInnerTextOptions) (string, error) 1054 // Returns `input.value` for `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements. 1055 InputValue(options ...FrameInputValueOptions) (string, error) 1056 // Returns whether the element is checked. Throws if the element is not a checkbox or radio input. 1057 IsChecked(options ...FrameIsCheckedOptions) (bool, error) 1058 // Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled). 1059 IsDisabled(options ...FrameIsDisabledOptions) (bool, error) 1060 // Returns whether the element is [editable](./actionability.md#editable). 1061 IsEditable(options ...FrameIsEditableOptions) (bool, error) 1062 // Returns whether the element is [enabled](./actionability.md#enabled). 1063 IsEnabled(options ...FrameIsEnabledOptions) (bool, error) 1064 // Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). 1065 IsHidden(options ...FrameIsHiddenOptions) (bool, error) 1066 // Returns whether the element is [visible](./actionability.md#visible). 1067 IsVisible(options ...FrameIsVisibleOptions) (bool, error) 1068 // Returns locator to the last matching element. 1069 Last() (Locator, error) 1070 // The method finds an element matching the specified selector in the `Locator`'s subtree. 1071 Locator(selector string) (Locator, error) 1072 // Returns locator to the n-th matching element. 1073 Nth(index int) (Locator, error) 1074 // A page this locator belongs to. 1075 Page() Page 1076 // Focuses the element, and then uses Keyboard.down`] and [`method: Keyboard.up(). 1077 // `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) 1078 // value or a single character to generate the text for. A superset of the `key` values can be found 1079 // [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are: 1080 // `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, 1081 // `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc. 1082 // Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. 1083 // Holding down `Shift` will type the text that corresponds to the `key` in the upper case. 1084 // If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective 1085 // texts. 1086 // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the 1087 // modifier, modifier is pressed and being held while the subsequent key is being pressed. 1088 Press(key string, options ...PagePressOptions) error 1089 // Returns the buffer with the captured screenshot. 1090 // This method waits for the [actionability](./actionability.md) checks, then scrolls element into view before taking a 1091 // screenshot. If the element is detached from DOM, the method throws an error. 1092 Screenshot(options ...LocatorScreenshotOptions) ([]byte, error) 1093 // This method waits for [actionability](./actionability.md) checks, then tries to scroll element into view, unless it is 1094 // completely visible as defined by 1095 // [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`. 1096 ScrollIntoViewIfNeeded(options ...LocatorScrollIntoViewIfNeededOptions) error 1097 // This method waits for [actionability](./actionability.md) checks, waits until all specified options are present in the 1098 // `<select>` element and selects these options. 1099 // If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the 1100 // `<label>` element that has an associated 1101 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead. 1102 // Returns the array of option values that have been successfully selected. 1103 // Triggers a `change` and `input` event once all the provided options have been selected. 1104 SelectOption(values SelectOptionValues, options ...FrameSelectOptionOptions) ([]string, error) 1105 // This method waits for [actionability](./actionability.md) checks, then focuses the element and selects all its text 1106 // content. 1107 SelectText(options ...LocatorSelectTextOptions) error 1108 // This method checks or unchecks an element by performing the following steps: 1109 // 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. 1110 // 1. If the element already has the right checked state, this method returns immediately. 1111 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1112 // element is detached during the checks, the whole action is retried. 1113 // 1. Scroll the element into view if needed. 1114 // 1. Use [`property: Page.mouse`] to click in the center of the element. 1115 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1116 // 1. Ensure that the element is now checked or unchecked. If not, this method throws. 1117 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1118 // zero timeout disables this. 1119 SetChecked(checked bool, options ...FrameSetCheckedOptions) error 1120 // This method expects `element` to point to an 1121 // [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). 1122 // Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they 1123 // are resolved relative to the the current working directory. For empty array, clears the selected files. 1124 SetInputFiles(files []InputFile, options ...FrameSetInputFilesOptions) error 1125 // This method taps the element by performing the following steps: 1126 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 1127 // 1. Scroll the element into view if needed. 1128 // 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`. 1129 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1130 // If the element is detached from the DOM at any moment during the action, this method throws. 1131 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1132 // zero timeout disables this. 1133 // > NOTE: `element.tap()` requires that the `hasTouch` option of the browser context be set to true. 1134 Tap(options ...FrameTapOptions) error 1135 // Returns the `node.textContent`. 1136 TextContent(options ...FrameTextContentOptions) (string, error) 1137 // Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. 1138 // To press a special key, like `Control` or `ArrowDown`, use Locator.press(). 1139 // An example of typing into a text field and then submitting the form: 1140 Type(text string, options ...PageTypeOptions) error 1141 // This method checks the element by performing the following steps: 1142 // 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already 1143 // unchecked, this method returns immediately. 1144 // 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set. 1145 // 1. Scroll the element into view if needed. 1146 // 1. Use [`property: Page.mouse`] to click in the center of the element. 1147 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1148 // 1. Ensure that the element is now unchecked. If not, this method throws. 1149 // If the element is detached from the DOM at any moment during the action, this method throws. 1150 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1151 // zero timeout disables this. 1152 Uncheck(options ...FrameUncheckOptions) error 1153 // Returns when element specified by locator satisfies the `state` option. 1154 // If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to `timeout` 1155 // milliseconds until the condition is met. 1156 WaitFor(options ...PageWaitForSelectorOptions) error 1157 } 1158 1159 // The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport. 1160 // Every `page` object has its own Mouse, accessible with [`property: Page.mouse`]. 1161 type Mouse interface { 1162 // Shortcut for Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up(). 1163 Click(x, y float64, options ...MouseClickOptions) error 1164 // Shortcut for Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`], [`method: Mouse.down() and 1165 // Mouse.up(). 1166 Dblclick(x, y float64, options ...MouseDblclickOptions) error 1167 // Dispatches a `mousedown` event. 1168 Down(options ...MouseDownOptions) error 1169 // Dispatches a `mousemove` event. 1170 Move(x float64, y float64, options ...MouseMoveOptions) error 1171 // Dispatches a `mouseup` event. 1172 Up(options ...MouseUpOptions) error 1173 } 1174 1175 // Page provides methods to interact with a single tab in a `Browser`, or an 1176 // [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One `Browser` 1177 // instance might have multiple `Page` instances. 1178 // This example creates a page, navigates it to a URL, and then saves a screenshot: 1179 // The Page class emits various events (described below) which can be handled using any of Node's native 1180 // [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or 1181 // `removeListener`. 1182 // This example logs a message for a single page `load` event: 1183 // To unsubscribe from events use the `removeListener` method: 1184 type Page interface { 1185 EventEmitter 1186 // This method checks or unchecks an element matching `selector` by performing the following steps: 1187 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1188 // 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. 1189 // 1. If the element already has the right checked state, this method returns immediately. 1190 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1191 // element is detached during the checks, the whole action is retried. 1192 // 1. Scroll the element into view if needed. 1193 // 1. Use [`property: Page.mouse`] to click in the center of the element. 1194 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1195 // 1. Ensure that the element is now checked or unchecked. If not, this method throws. 1196 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1197 // zero timeout disables this. 1198 // Shortcut for main frame's Frame.setChecked(). 1199 SetChecked(selector string, checked bool, options ...FrameSetCheckedOptions) error 1200 Mouse() Mouse 1201 Keyboard() Keyboard 1202 Touchscreen() Touchscreen 1203 // Adds a script which would be evaluated in one of the following scenarios: 1204 // - Whenever the page is navigated. 1205 // - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly 1206 // attached frame. 1207 // The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend 1208 // the JavaScript environment, e.g. to seed `Math.random`. 1209 // An example of overriding `Math.random` before the page loads: 1210 // > NOTE: The order of evaluation of multiple scripts installed via BrowserContext.addInitScript() and 1211 // Page.addInitScript() is not defined. 1212 AddInitScript(script PageAddInitScriptOptions) error 1213 // Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload 1214 // fires or when the script content was injected into frame. 1215 // Shortcut for main frame's Frame.addScriptTag(). 1216 AddScriptTag(options PageAddScriptTagOptions) (ElementHandle, error) 1217 // Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the 1218 // content. Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame. 1219 // Shortcut for main frame's Frame.addStyleTag(). 1220 AddStyleTag(options PageAddStyleTagOptions) (ElementHandle, error) 1221 // Brings page to front (activates tab). 1222 BringToFront() error 1223 // This method checks an element matching `selector` by performing the following steps: 1224 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1225 // 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already 1226 // checked, this method returns immediately. 1227 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1228 // element is detached during the checks, the whole action is retried. 1229 // 1. Scroll the element into view if needed. 1230 // 1. Use [`property: Page.mouse`] to click in the center of the element. 1231 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1232 // 1. Ensure that the element is now checked. If not, this method throws. 1233 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1234 // zero timeout disables this. 1235 // Shortcut for main frame's Frame.check(). 1236 Check(selector string, options ...FrameCheckOptions) error 1237 // This method clicks an element matching `selector` by performing the following steps: 1238 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1239 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1240 // element is detached during the checks, the whole action is retried. 1241 // 1. Scroll the element into view if needed. 1242 // 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`. 1243 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1244 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1245 // zero timeout disables this. 1246 // Shortcut for main frame's Frame.click(). 1247 Click(selector string, options ...PageClickOptions) error 1248 // If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed. If 1249 // `runBeforeUnload` is `true` the method will run unload handlers, but will **not** wait for the page to close. 1250 // By default, `page.close()` **does not** run `beforeunload` handlers. 1251 // > NOTE: if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned and should be handled manually 1252 // via [`event: Page.dialog`] event. 1253 Close(options ...PageCloseOptions) error 1254 // Gets the full HTML contents of the page, including the doctype. 1255 Content() (string, error) 1256 // Get the browser context that the page belongs to. 1257 Context() BrowserContext 1258 // This method double clicks an element matching `selector` by performing the following steps: 1259 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1260 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1261 // element is detached during the checks, the whole action is retried. 1262 // 1. Scroll the element into view if needed. 1263 // 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`. 1264 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the 1265 // first click of the `dblclick()` triggers a navigation event, this method will throw. 1266 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1267 // zero timeout disables this. 1268 // > NOTE: `page.dblclick()` dispatches two `click` events and a single `dblclick` event. 1269 // Shortcut for main frame's Frame.dblclick(). 1270 Dblclick(expression string, options ...FrameDblclickOptions) error 1271 // The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, 1272 // `click` is dispatched. This is equivalent to calling 1273 // [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click). 1274 // Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties 1275 // and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default. 1276 // Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties: 1277 // - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent) 1278 // - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent) 1279 // - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent) 1280 // - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent) 1281 // - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent) 1282 // - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent) 1283 // - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event) 1284 // You can also specify `JSHandle` as the property value if you want live objects to be passed into the event: 1285 DispatchEvent(selector string, typ string, options ...PageDispatchEventOptions) error 1286 // The method adds a function called `name` on the `window` object of every frame in this page. When called, the function 1287 // executes `callback` and returns a [Promise] which resolves to the return value of `callback`. If the `callback` returns 1288 // a [Promise], it will be awaited. 1289 // The first argument of the `callback` function contains information about the caller: `{ browserContext: BrowserContext, 1290 // page: Page, frame: Frame }`. 1291 // See BrowserContext.exposeBinding() for the context-wide version. 1292 // > NOTE: Functions installed via Page.exposeBinding() survive navigations. 1293 // An example of exposing page URL to all frames in a page: 1294 // An example of passing an element handle: 1295 ExposeBinding(name string, binding BindingCallFunction, handle ...bool) error 1296 // The method adds a function called `name` on the `window` object of every frame in the page. When called, the function 1297 // executes `callback` and returns a [Promise] which resolves to the return value of `callback`. 1298 // If the `callback` returns a [Promise], it will be awaited. 1299 // See BrowserContext.exposeFunction() for context-wide exposed function. 1300 // > NOTE: Functions installed via Page.exposeFunction() survive navigations. 1301 // An example of adding a `sha256` function to the page: 1302 ExposeFunction(name string, binding ExposedFunction) error 1303 // This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media 1304 // feature, using the `colorScheme` argument. 1305 EmulateMedia(options ...PageEmulateMediaOptions) error 1306 // Returns the value of the `expression` invocation. 1307 // If the function passed to the Page.evaluate`] returns a [Promise], then [`method: Page.evaluate() would wait 1308 // for the promise to resolve and return its value. 1309 // If the function passed to the Page.evaluate() returns a non-[Serializable] value, then 1310 // Page.evaluate() resolves to `undefined`. Playwright also supports transferring some additional values that are 1311 // not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`. 1312 // Passing argument to `expression`: 1313 // A string can also be passed in instead of a function: 1314 // `ElementHandle` instances can be passed as an argument to the Page.evaluate(): 1315 // Shortcut for main frame's Frame.evaluate(). 1316 Evaluate(expression string, options ...interface{}) (interface{}, error) 1317 // Returns the value of the `expression` invocation as a `JSHandle`. 1318 // The only difference between Page.evaluate`] and [`method: Page.evaluateHandle() is that 1319 // Page.evaluateHandle() returns `JSHandle`. 1320 // If the function passed to the Page.evaluateHandle`] returns a [Promise], then [`method: Page.evaluateHandle() 1321 // would wait for the promise to resolve and return its value. 1322 // A string can also be passed in instead of a function: 1323 // `JSHandle` instances can be passed as an argument to the Page.evaluateHandle(): 1324 EvaluateHandle(expression string, options ...interface{}) (JSHandle, error) 1325 // > NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky 1326 // tests. Use Locator.evaluate(), other `Locator` helper methods or web-first assertions instead. 1327 // The method finds an element matching the specified selector within the page and passes it as a first argument to 1328 // `expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`. 1329 // If `expression` returns a [Promise], then Page.evalOnSelector() would wait for the promise to resolve and 1330 // return its value. 1331 // Examples: 1332 // Shortcut for main frame's Frame.evalOnSelector(). 1333 EvalOnSelector(selector string, expression string, options ...interface{}) (interface{}, error) 1334 // > NOTE: In most cases, Locator.evaluateAll(), other `Locator` helper methods and web-first assertions do a 1335 // better job. 1336 // The method finds all elements matching the specified selector within the page and passes an array of matched elements as 1337 // a first argument to `expression`. Returns the result of `expression` invocation. 1338 // If `expression` returns a [Promise], then Page.evalOnSelectorAll() would wait for the promise to resolve and 1339 // return its value. 1340 // Examples: 1341 EvalOnSelectorAll(selector string, expression string, options ...interface{}) (interface{}, error) 1342 ExpectConsoleMessage(cb func() error) (ConsoleMessage, error) 1343 ExpectDownload(cb func() error) (Download, error) 1344 ExpectEvent(event string, cb func() error, predicates ...interface{}) (interface{}, error) 1345 ExpectFileChooser(cb func() error) (FileChooser, error) 1346 ExpectLoadState(state string, cb func() error) error 1347 ExpectNavigation(cb func() error, options ...PageWaitForNavigationOptions) (Response, error) 1348 ExpectPopup(cb func() error) (Page, error) 1349 ExpectRequest(url interface{}, cb func() error, options ...interface{}) (Request, error) 1350 ExpectResponse(url interface{}, cb func() error, options ...interface{}) (Response, error) 1351 ExpectWorker(cb func() error) (Worker, error) 1352 ExpectedDialog(cb func() error) (Dialog, error) 1353 // This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the 1354 // element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input 1355 // field. 1356 // If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. 1357 // However, if the element is inside the `<label>` element that has an associated 1358 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled 1359 // instead. 1360 // To send fine-grained keyboard events, use Page.type(). 1361 // Shortcut for main frame's Frame.fill(). 1362 Fill(selector, text string, options ...FrameFillOptions) error 1363 // This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method 1364 // waits until a matching element appears in the DOM. 1365 // Shortcut for main frame's Frame.focus(). 1366 Focus(expression string, options ...FrameFocusOptions) error 1367 // Returns frame matching the specified criteria. Either `name` or `url` must be specified. 1368 Frame(options PageFrameOptions) Frame 1369 // An array of all frames attached to the page. 1370 Frames() []Frame 1371 // Returns element attribute value. 1372 GetAttribute(selector string, name string, options ...PageGetAttributeOptions) (string, error) 1373 // Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the 1374 // last redirect. If can not go back, returns `null`. 1375 // Navigate to the previous page in history. 1376 GoBack(options ...PageGoBackOptions) (Response, error) 1377 // Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the 1378 // last redirect. If can not go forward, returns `null`. 1379 // Navigate to the next page in history. 1380 GoForward(options ...PageGoForwardOptions) (Response, error) 1381 // Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the 1382 // last redirect. 1383 // The method will throw an error if: 1384 // - there's an SSL error (e.g. in case of self-signed certificates). 1385 // - target URL is invalid. 1386 // - the `timeout` is exceeded during navigation. 1387 // - the remote server does not respond or is unreachable. 1388 // - the main resource failed to load. 1389 // The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not 1390 // Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling 1391 // Response.status(). 1392 // > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to 1393 // `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`. 1394 // > NOTE: Headless mode doesn't support navigation to a PDF document. See the 1395 // [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295). 1396 // Shortcut for main frame's Frame.goto() 1397 Goto(url string, options ...PageGotoOptions) (Response, error) 1398 // This method hovers over an element matching `selector` by performing the following steps: 1399 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1400 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1401 // element is detached during the checks, the whole action is retried. 1402 // 1. Scroll the element into view if needed. 1403 // 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`. 1404 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1405 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1406 // zero timeout disables this. 1407 // Shortcut for main frame's Frame.hover(). 1408 Hover(selector string, options ...PageHoverOptions) error 1409 // Returns `element.innerHTML`. 1410 InnerHTML(selector string, options ...PageInnerHTMLOptions) (string, error) 1411 // Returns `element.innerText`. 1412 InnerText(selector string, options ...PageInnerTextOptions) (string, error) 1413 // Indicates that the page has been closed. 1414 IsClosed() bool 1415 // Returns whether the element is checked. Throws if the element is not a checkbox or radio input. 1416 IsChecked(selector string, options ...FrameIsCheckedOptions) (bool, error) 1417 // Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled). 1418 IsDisabled(selector string, options ...FrameIsDisabledOptions) (bool, error) 1419 // Returns whether the element is [editable](./actionability.md#editable). 1420 IsEditable(selector string, options ...FrameIsEditableOptions) (bool, error) 1421 // Returns whether the element is [enabled](./actionability.md#enabled). 1422 IsEnabled(selector string, options ...FrameIsEnabledOptions) (bool, error) 1423 // Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). `selector` that does not 1424 // match any elements is considered hidden. 1425 IsHidden(selector string, options ...FrameIsHiddenOptions) (bool, error) 1426 // Returns whether the element is [visible](./actionability.md#visible). `selector` that does not match any elements is 1427 // considered not visible. 1428 IsVisible(selector string, options ...FrameIsVisibleOptions) (bool, error) 1429 // The method returns an element locator that can be used to perform actions on the page. Locator is resolved to the 1430 // element immediately before performing an action, so a series of actions on the same locator can in fact be performed on 1431 // different DOM elements. That would happen if the DOM structure between those actions has changed. 1432 // Shortcut for main frame's Frame.locator(). 1433 Locator(selector string, options ...PageLocatorOptions) (Locator, error) 1434 // The page's main frame. Page is guaranteed to have a main frame which persists during navigations. 1435 MainFrame() Frame 1436 // Returns the opener for popup pages and `null` for others. If the opener has been closed already the returns `null`. 1437 Opener() (Page, error) 1438 // Returns the PDF buffer. 1439 // > NOTE: Generating a pdf is currently only supported in Chromium headless. 1440 // `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call 1441 // Page.emulateMedia() before calling `page.pdf()`: 1442 // > NOTE: By default, `page.pdf()` generates a pdf with modified colors for printing. Use the 1443 // [`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to 1444 // force rendering of exact colors. 1445 // The `width`, `height`, and `margin` options accept values labeled with units. Unlabeled values are treated as pixels. 1446 // A few examples: 1447 // - `page.pdf({width: 100})` - prints with width set to 100 pixels 1448 // - `page.pdf({width: '100px'})` - prints with width set to 100 pixels 1449 // - `page.pdf({width: '10cm'})` - prints with width set to 10 centimeters. 1450 // All possible units are: 1451 // - `px` - pixel 1452 // - `in` - inch 1453 // - `cm` - centimeter 1454 // - `mm` - millimeter 1455 // The `format` options are: 1456 // - `Letter`: 8.5in x 11in 1457 // - `Legal`: 8.5in x 14in 1458 // - `Tabloid`: 11in x 17in 1459 // - `Ledger`: 17in x 11in 1460 // - `A0`: 33.1in x 46.8in 1461 // - `A1`: 23.4in x 33.1in 1462 // - `A2`: 16.54in x 23.4in 1463 // - `A3`: 11.7in x 16.54in 1464 // - `A4`: 8.27in x 11.7in 1465 // - `A5`: 5.83in x 8.27in 1466 // - `A6`: 4.13in x 5.83in 1467 // > NOTE: `headerTemplate` and `footerTemplate` markup have the following limitations: > 1. Script tags inside templates 1468 // are not evaluated. > 2. Page styles are not visible inside templates. 1469 PDF(options ...PagePdfOptions) ([]byte, error) 1470 // Focuses the element, and then uses Keyboard.down`] and [`method: Keyboard.up(). 1471 // `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) 1472 // value or a single character to generate the text for. A superset of the `key` values can be found 1473 // [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are: 1474 // `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, 1475 // `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc. 1476 // Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`. 1477 // Holding down `Shift` will type the text that corresponds to the `key` in the upper case. 1478 // If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective 1479 // texts. 1480 // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the 1481 // modifier, modifier is pressed and being held while the subsequent key is being pressed. 1482 Press(selector, key string, options ...PagePressOptions) error 1483 // > NOTE: The use of `ElementHandle` is discouraged, use `Locator` objects and web-first assertions instead. 1484 // The method finds an element matching the specified selector within the page. If no elements match the selector, the 1485 // return value resolves to `null`. To wait for an element on the page, use Locator.waitFor(). 1486 // Shortcut for main frame's Frame.querySelector(). 1487 QuerySelector(selector string) (ElementHandle, error) 1488 // > NOTE: The use of `ElementHandle` is discouraged, use `Locator` objects and web-first assertions instead. 1489 // The method finds all elements matching the specified selector within the page. If no elements match the selector, the 1490 // return value resolves to `[]`. 1491 // Shortcut for main frame's Frame.querySelectorAll(). 1492 QuerySelectorAll(selector string) ([]ElementHandle, error) 1493 // This method reloads the current page, in the same way as if the user had triggered a browser refresh. Returns the main 1494 // resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. 1495 Reload(options ...PageReloadOptions) (Response, error) 1496 // Routing provides the capability to modify network requests that are made by a page. 1497 // Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted. 1498 // > NOTE: The handler will only be called for the first url if the response is a redirect. 1499 // > NOTE: Page.route() will not intercept requests intercepted by Service Worker. See 1500 // [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using 1501 // request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);` 1502 // An example of a naive handler that aborts all image requests: 1503 // or the same snippet using a regex pattern instead: 1504 // It is possible to examine the request to decide the route action. For example, mocking all requests that contain some 1505 // post data, and leaving all other requests as is: 1506 // Page routes take precedence over browser context routes (set up with BrowserContext.route()) when request 1507 // matches both handlers. 1508 // To remove a route with its handler you can use Page.unroute(). 1509 // > NOTE: Enabling routing disables http cache. 1510 Route(url interface{}, handler routeHandler) error 1511 // Returns the buffer with the captured screenshot. 1512 Screenshot(options ...PageScreenshotOptions) ([]byte, error) 1513 // This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, waits until 1514 // all specified options are present in the `<select>` element and selects these options. 1515 // If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the 1516 // `<label>` element that has an associated 1517 // [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead. 1518 // Returns the array of option values that have been successfully selected. 1519 // Triggers a `change` and `input` event once all the provided options have been selected. 1520 // Shortcut for main frame's Frame.selectOption(). 1521 SelectOption(selector string, values SelectOptionValues, options ...FrameSelectOptionOptions) ([]string, error) 1522 SetContent(content string, options ...PageSetContentOptions) error 1523 // This setting will change the default maximum navigation time for the following methods and related shortcuts: 1524 // - Page.goBack() 1525 // - Page.goForward() 1526 // - Page.goto() 1527 // - Page.reload() 1528 // - Page.setContent() 1529 // - Page.waitForNavigation() 1530 // - Page.waitForURL() 1531 // > NOTE: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout(), 1532 // BrowserContext.setDefaultTimeout`] and [`method: BrowserContext.setDefaultNavigationTimeout(). 1533 SetDefaultNavigationTimeout(timeout float64) 1534 // This setting will change the default maximum time for all the methods accepting `timeout` option. 1535 // > NOTE: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout(). 1536 SetDefaultTimeout(timeout float64) 1537 // The extra HTTP headers will be sent with every request the page initiates. 1538 // > NOTE: Page.setExtraHTTPHeaders() does not guarantee the order of headers in the outgoing requests. 1539 SetExtraHTTPHeaders(headers map[string]string) error 1540 // This method expects `selector` to point to an 1541 // [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). 1542 // Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they 1543 // are resolved relative to the the current working directory. For empty array, clears the selected files. 1544 SetInputFiles(selector string, files []InputFile, options ...FrameSetInputFilesOptions) error 1545 // In the case of multiple pages in a single browser, each page can have its own viewport size. However, 1546 // Browser.newContext() allows to set viewport size (and more) for all pages in the context at once. 1547 // Page.setViewportSize() will resize the page. A lot of websites don't expect phones to change size, so you 1548 // should set the viewport size before navigating to the page. Page.setViewportSize() will also reset `screen` 1549 // size, use Browser.newContext() with `screen` and `viewport` parameters if you need better control of these 1550 // properties. 1551 SetViewportSize(width, height int) error 1552 // This method taps an element matching `selector` by performing the following steps: 1553 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1554 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1555 // element is detached during the checks, the whole action is retried. 1556 // 1. Scroll the element into view if needed. 1557 // 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`. 1558 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1559 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1560 // zero timeout disables this. 1561 // > NOTE: Page.tap() requires that the `hasTouch` option of the browser context be set to true. 1562 // Shortcut for main frame's Frame.tap(). 1563 Tap(selector string, options ...FrameTapOptions) error 1564 // Returns `element.textContent`. 1565 TextContent(selector string, options ...FrameTextContentOptions) (string, error) 1566 // Returns the page's title. Shortcut for main frame's Frame.title(). 1567 Title() (string, error) 1568 // Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send 1569 // fine-grained keyboard events. To fill values in form fields, use Page.fill(). 1570 // To press a special key, like `Control` or `ArrowDown`, use Keyboard.press(). 1571 // Shortcut for main frame's Frame.type(). 1572 Type(selector, text string, options ...PageTypeOptions) error 1573 // Shortcut for main frame's Frame.url(). 1574 URL() string 1575 // This method unchecks an element matching `selector` by performing the following steps: 1576 // 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1577 // 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already 1578 // unchecked, this method returns immediately. 1579 // 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the 1580 // element is detached during the checks, the whole action is retried. 1581 // 1. Scroll the element into view if needed. 1582 // 1. Use [`property: Page.mouse`] to click in the center of the element. 1583 // 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. 1584 // 1. Ensure that the element is now unchecked. If not, this method throws. 1585 // When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing 1586 // zero timeout disables this. 1587 // Shortcut for main frame's Frame.uncheck(). 1588 Uncheck(selector string, options ...FrameUncheckOptions) error 1589 // Removes a route created with Page.route(). When `handler` is not specified, removes all routes for the `url`. 1590 Unroute(url interface{}, handler ...routeHandler) error 1591 // Video object associated with this page. 1592 Video() Video 1593 ViewportSize() ViewportSize 1594 // Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy 1595 // value. Will throw an error if the page is closed before the event is fired. Returns the event data value. 1596 WaitForEvent(event string, predicate ...interface{}) interface{} 1597 // Returns when the `expression` returns a truthy value. It resolves to a JSHandle of the truthy value. 1598 // The Page.waitForFunction() can be used to observe viewport size change: 1599 // To pass an argument to the predicate of Page.waitForFunction() function: 1600 // Shortcut for main frame's Frame.waitForFunction(). 1601 WaitForFunction(expression string, arg interface{}, options ...FrameWaitForFunctionOptions) (JSHandle, error) 1602 // Returns when the required load state has been reached. 1603 // This resolves when the page reaches a required load state, `load` by default. The navigation must have been committed 1604 // when this method is called. If current document has already reached the required state, resolves immediately. 1605 // Shortcut for main frame's Frame.waitForLoadState(). 1606 WaitForLoadState(state ...string) 1607 // Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the 1608 // navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or 1609 // navigation due to History API usage, the navigation will resolve with `null`. 1610 // This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly 1611 // cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`. 1612 // Consider this example: 1613 // > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is 1614 // considered a navigation. 1615 // Shortcut for main frame's Frame.waitForNavigation(). 1616 WaitForNavigation(options ...PageWaitForNavigationOptions) (Response, error) 1617 // Waits for the matching request and returns it. See [waiting for event](./events.md#waiting-for-event) for more details 1618 // about events. 1619 WaitForRequest(url interface{}, options ...interface{}) Request 1620 // Returns the matched response. See [waiting for event](./events.md#waiting-for-event) for more details about events. 1621 WaitForResponse(url interface{}, options ...interface{}) Response 1622 // Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or 1623 // `detached`. 1624 // > NOTE: Playwright automatically waits for element to be ready before performing an action. Using `Locator` objects and 1625 // web-first assertions make the code wait-for-selector-free. 1626 // Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at 1627 // the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the 1628 // selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw. 1629 // This method works across navigations: 1630 WaitForSelector(selector string, options ...PageWaitForSelectorOptions) (ElementHandle, error) 1631 // Waits for the given `timeout` in milliseconds. 1632 // Note that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be 1633 // flaky. Use signals such as network events, selectors becoming visible and others instead. 1634 // Shortcut for main frame's Frame.waitForTimeout(). 1635 WaitForTimeout(timeout float64) 1636 // This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) 1637 // associated with the page. 1638 // > NOTE: This does not contain ServiceWorkers 1639 Workers() []Worker 1640 DragAndDrop(source, target string, options ...FrameDragAndDropOptions) error 1641 // Pauses script execution. Playwright will stop executing the script and wait for the user to either press 'Resume' button 1642 // in the page overlay or to call `playwright.resume()` in the DevTools console. 1643 // User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from 1644 // the place it was paused. 1645 // > NOTE: This method requires Playwright to be started in a headed mode, with a falsy `headless` value in the 1646 // BrowserType.launch(). 1647 Pause() error 1648 // Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements. 1649 InputValue(selector string, options ...FrameInputValueOptions) (string, error) 1650 // Waits for the main frame to navigate to the given URL. 1651 // Shortcut for main frame's Frame.waitForURL(). 1652 WaitForURL(url string, options ...FrameWaitForURLOptions) error 1653 } 1654 1655 // Whenever the page sends a request for a network resource the following sequence of events are emitted by `Page`: 1656 // - [`event: Page.request`] emitted when the request is issued by the page. 1657 // - [`event: Page.response`] emitted when/if the response status and headers are received for the request. 1658 // - [`event: Page.requestFinished`] emitted when the response body is downloaded and the request is complete. 1659 // If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event), 1660 // the [`event: Page.requestFailed`] event is emitted. 1661 // > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will 1662 // complete with `'requestfinished'` event. 1663 // If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new 1664 // request is issued to a redirected url. 1665 type Request interface { 1666 // An object with all the request HTTP headers associated with this request. The header names are lower-cased. 1667 AllHeaders() (map[string]string, error) 1668 // An array with all the request HTTP headers associated with this request. Unlike Request.allHeaders(), header 1669 // names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times. 1670 HeadersArray() (HeadersArray, error) 1671 // Returns the value of the header matching the name. The name is case insensitive. 1672 HeaderValue(name string) (string, error) 1673 HeaderValues(name string) ([]string, error) 1674 // The method returns `null` unless this request has failed, as reported by `requestfailed` event. 1675 // Example of logging of all the failed requests: 1676 Failure() *RequestFailure 1677 // Returns the `Frame` that initiated this request. 1678 Frame() Frame 1679 // **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use Request.allHeaders() instead. 1680 Headers() map[string]string 1681 // Whether this request is driving frame's navigation. 1682 IsNavigationRequest() bool 1683 // Request's method (GET, POST, etc.) 1684 Method() string 1685 // Request's post body, if any. 1686 PostData() (string, error) 1687 // Request's post body in a binary form, if any. 1688 PostDataBuffer() ([]byte, error) 1689 // Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. 1690 // When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned. 1691 // Otherwise it will be parsed as JSON. 1692 PostDataJSON(v interface{}) error 1693 // Request that was redirected by the server to this one, if any. 1694 // When the server responds with a redirect, Playwright creates a new `Request` object. The two requests are connected by 1695 // `redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to 1696 // construct the whole redirect chain by repeatedly calling `redirectedFrom()`. 1697 // For example, if the website `http://example.com` redirects to `https://example.com`: 1698 // If the website `https://google.com` has no redirects: 1699 RedirectedFrom() Request 1700 // New request issued by the browser if the server responded with redirect. 1701 // This method is the opposite of Request.redirectedFrom(): 1702 RedirectedTo() Request 1703 // Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the 1704 // following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`, 1705 // `websocket`, `manifest`, `other`. 1706 ResourceType() string 1707 // Returns the matching `Response` object, or `null` if the response was not received due to error. 1708 Response() (Response, error) 1709 // Returns resource timing information for given request. Most of the timing values become available upon the response, 1710 // `responseEnd` becomes available when request finishes. Find more information at 1711 // [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming). 1712 Timing() *ResourceTiming 1713 // URL of the request. 1714 URL() string 1715 // Returns resource size information for given request. 1716 Sizes() (*RequestSizesResult, error) 1717 } 1718 1719 // `Response` class represents responses which are received by page. 1720 type Response interface { 1721 // An object with all the response HTTP headers associated with this response. 1722 AllHeaders() (map[string]string, error) 1723 // An array with all the request HTTP headers associated with this response. Unlike Response.allHeaders(), header 1724 // names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times. 1725 HeadersArray() (HeadersArray, error) 1726 // Returns the value of the header matching the name. The name is case insensitive. If multiple headers have the same name 1727 // (except `set-cookie`), they are returned as a list separated by `, `. For `set-cookie`, the `\n` separator is used. If 1728 // no headers are found, `null` is returned. 1729 HeaderValue(name string) (string, error) 1730 // Returns all values of the headers matching the name, for example `set-cookie`. The name is case insensitive. 1731 HeaderValues(name string) ([]string, error) 1732 // Returns the buffer with response body. 1733 Body() ([]byte, error) 1734 // Waits for this response to finish, returns always `null`. 1735 Finished() 1736 // Returns the `Frame` that initiated this response. 1737 Frame() Frame 1738 // **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use Response.allHeaders() instead. 1739 Headers() map[string]string 1740 // Returns the JSON representation of response body. 1741 // This method will throw if the response body is not parsable via `JSON.parse`. 1742 JSON(v interface{}) error 1743 // Contains a boolean stating whether the response was successful (status in the range 200-299) or not. 1744 Ok() bool 1745 // Returns the matching `Request` object. 1746 Request() Request 1747 // Contains the status code of the response (e.g., 200 for a success). 1748 Status() int 1749 // Contains the status text of the response (e.g. usually an "OK" for a success). 1750 StatusText() string 1751 // Returns the text representation of response body. 1752 Text() (string, error) 1753 // Contains the URL of the response. 1754 URL() string 1755 // Returns SSL and other security information. 1756 SecurityDetails() (*ResponseSecurityDetailsResult, error) 1757 // Returns the IP address and port of the server. 1758 ServerAddr() (*ResponseServerAddrResult, error) 1759 } 1760 1761 // Whenever a network route is set up with Page.route`] or [`method: BrowserContext.route(), the `Route` object 1762 // allows to handle the route. 1763 type Route interface { 1764 // Aborts the route's request. 1765 Abort(errorCode ...string) error 1766 // Continues route's request with optional overrides. 1767 Continue(options ...RouteContinueOptions) error 1768 // Fulfills route's request with given response. 1769 // An example of fulfilling all requests with 404 responses: 1770 // An example of serving static file: 1771 Fulfill(options RouteFulfillOptions) error 1772 // A request to be routed. 1773 Request() Request 1774 } 1775 1776 // The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the 1777 // touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true. 1778 type Touchscreen interface { 1779 // Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`). 1780 Tap(x int, y int) error 1781 } 1782 1783 // The `WebSocket` class represents websocket connections in the page. 1784 type WebSocket interface { 1785 EventEmitter 1786 // Indicates that the web socket has been closed. 1787 IsClosed() bool 1788 // Contains the URL of the WebSocket. 1789 URL() string 1790 // Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy 1791 // value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value. 1792 WaitForEvent(event string, predicate ...interface{}) interface{} 1793 } 1794 1795 // When browser context is created with the `recordVideo` option, each page has a video object associated with it. 1796 type Video interface { 1797 // Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem 1798 // upon closing the browser context. This method throws when connected remotely. 1799 Path() (string, error) 1800 // Deletes the video file. Will wait for the video to finish if necessary. 1801 Delete() error 1802 // Saves the video to a user-specified path. It is safe to call this method while the video is still in progress, or after 1803 // the page has closed. This method waits until the page is closed and the video is fully saved. 1804 SaveAs(path string) error 1805 } 1806 1807 // The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker` 1808 // event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the 1809 // worker is gone. 1810 type Worker interface { 1811 EventEmitter 1812 // Returns the return value of `expression`. 1813 // If the function passed to the Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate() would 1814 // wait for the promise to resolve and return its value. 1815 // If the function passed to the Worker.evaluate() returns a non-[Serializable] value, then 1816 // Worker.evaluate() returns `undefined`. Playwright also supports transferring some additional values that are 1817 // not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`. 1818 Evaluate(expression string, options ...interface{}) (interface{}, error) 1819 // Returns the return value of `expression` as a `JSHandle`. 1820 // The only difference between Worker.evaluate`] and [`method: Worker.evaluateHandle() is that 1821 // Worker.evaluateHandle() returns `JSHandle`. 1822 // If the function passed to the Worker.evaluateHandle() returns a [Promise], then 1823 // Worker.evaluateHandle() would wait for the promise to resolve and return its value. 1824 EvaluateHandle(expression string, options ...interface{}) (JSHandle, error) 1825 URL() string 1826 WaitForEvent(event string, predicate ...interface{}) interface{} 1827 ExpectEvent(event string, cb func() error, predicates ...interface{}) (interface{}, error) 1828 } 1829