Playwright Other Api
This appendix lists the APIs for auxiliary classes such as Dialog, Download, Video, Tracing, etc.
* * *
## Dialog Class
| Method | Description |
| --- | --- |
| `dialog.accept(promptText?)` | Confirm the dialog |
| `dialog.dismiss()` | Dismiss the dialog |
| `dialog.message()` | Dialog message |
| `dialog.type()` | Dialog type: `'alert'` | `'confirm'` | `'prompt'` | `'beforeunload'` |
| `dialog.defaultValue()` | Default input value of the dialog |
| `dialog.page()` | Page that owns the dialog |
* * *
## Download Class
| Method | Description |
| --- | --- |
| `download.saveAs(path)` | Save file to specified path |
| `download.suggestedFilename()` | Get suggested filename |
| `download.url()` | Download URL |
| `download.page()` | Owning page |
| `download.failure()` | Download failure information (returns null if no failure) |
| `download.delete()` | Delete downloaded file |
* * *
## FileChooser Class
| Method | Description |
| --- | --- |
| `fileChooser.setFiles(files, options?)` | Select files |
| `fileChooser.isMultiple()` | Whether multiple selection mode |
| `fileChooser.page()` | Owning page |
* * *
## ConsoleMessage Class
| Method | Description |
| --- | --- |
| `consoleMessage.type()` | Message type: `'log'` | `'error'` | `'warning'` | `'info'` | `'debug'` |
| `consoleMessage.text()` | Message text |
| `consoleMessage.location()` | Message source location |
| `consoleMessage.args()` | Message arguments (JSHandle array) |
* * *
## Video Class
| Method | Description |
| --- | --- |
| `video.saveAs(path)` | Save video to file |
| `video.delete()` | Delete video file |
| `video.path()` | Video file path |
* * *
## Tracing Class
| Method | Description |
| --- | --- |
| `tracing.start(options?)` | Start recording Trace |
| `tracing.startChunk(options?)` | Start new Trace chunk |
| `tracing.stopChunk(options?)` | Stop Trace chunk and save |
| `tracing.stop(options?)` | Stop recording and save Trace |
* * *
## Clock Class
| Method | Description |
| --- | --- |
| `clock.install(options?)` | Install fake clock |
| `clock.pauseAt(time)` | Pause at specified time |
| `clock.resume()` | Resume execution |
| `clock.setFixedTime(time)` | Set fixed time |
| `clock.fastForward(time)` | Fast forward time |
| `clock.runFor(time)` | Run for specified time |
* * *
## Selectors Class
| Method | Description |
| --- | --- |
| `selectors.register(name, script, options?)` | Register custom selector engine |
* * *
## ElementHandle Class
| Method | Description |
| --- | --- |
| `elementHandle.click(options?)` | Click |
| `elementHandle.fill(value)` | Fill in text |
| `elementHandle.screenshot(options?)` | Element screenshot |
| `elementHandle.boundingBox()` | Get position and size |
| `elementHandle.getAttribute(name)` | Get attribute |
| `elementHandle.textContent()` | Get text |
| `elementHandle.ownerFrame()` | Owning Frame |
* * *
## JSHandle Class
| Method | Description |
| --- | --- |
| `jsHandle.evaluate(fn, arg?)` | Execute JS |
| `jsHandle.getProperty(name)` | Get property |
| `jsHandle.getProperties()` | Get all properties |
| `jsHandle.jsonValue()` | Get JSON value |
| `jsHandle.dispose()` | Release resources |
* * *
## CDPSession Class
| Method | Description |
| --- | --- |
| `cdpSession.send(method, params?)` | Send CDP command |
| `cdpSession.detach()` | Detach CDP session |
* * *
## Worker Class
| Method/Event | Description |
| --- | --- |
| `worker.url()` | Worker URL |
| `worker.evaluate(fn, arg?)` | Execute JS in Worker |
| `worker.on('close', handler)` | Worker close event |
* * *
## Frame Class
| Method | Description |
| --- | --- |
| `frame.name()` | Frame name |
| `frame.url()` | Frame URL |
| `frame.goto(url, options?)` | Frame navigation |
| `frame.locator(selector)` | CSS/XPath locator |
| `frame.getByRole(role, options?)` | Locate by role |
| `frame.getByText(text)` | Locate by text |
| `frame.evaluate(fn, arg?)` | Execute JS |
| `frame.content()` | Get HTML content |
| `frame.parentFrame()` | Parent Frame |
| `frame.childFrames()` | Child Frame list |
* * *
## Error Classes
| Class | Description |
| --- | --- |
| `PlaywrightException` | General Playwright exception |
| `TimeoutError` | Timeout error (assertion timeout, operation timeout, etc.) |
YouTip