2021-01-07 16:12:25 -08:00
|
|
|
## async method: Playwright.stop
|
|
|
|
* langs: python
|
|
|
|
|
|
|
|
Terminates this instance of Playwright in case it was created bypassing the Python context manager. This is useful in REPL applications.
|
|
|
|
|
|
|
|
```py
|
|
|
|
>>> from playwright import sync_playwright
|
|
|
|
|
|
|
|
>>> playwright = sync_playwright().start()
|
|
|
|
|
|
|
|
>>> browser = playwright.chromium.launch()
|
|
|
|
>>> page = browser.newPage()
|
|
|
|
>>> page.goto("http://whatsmyuseragent.org/")
|
|
|
|
>>> page.screenshot(path="example.png")
|
|
|
|
>>> browser.close()
|
|
|
|
|
|
|
|
>>> playwright.stop()
|
|
|
|
```
|
|
|
|
|
|
|
|
### param: BrowserContext.addInitScript.path
|
|
|
|
* langs: python
|
|
|
|
- `path` <[path]>
|
|
|
|
|
|
|
|
Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. Optional.
|
|
|
|
|
|
|
|
|
|
|
|
### param: BrowserContext.addInitScript.script
|
|
|
|
* langs: python
|
|
|
|
- `script` <[string]>
|
|
|
|
|
|
|
|
Script to be evaluated in all pages in the browser context. Optional.
|
|
|
|
|
|
|
|
### param: Page.addInitScript.path
|
|
|
|
* langs: python
|
|
|
|
- `path` <[path]>
|
|
|
|
|
|
|
|
Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory. Optional.
|
|
|
|
|
|
|
|
### param: Page.addInitScript.script
|
|
|
|
* langs: python
|
|
|
|
- `script` <[string]>
|
|
|
|
|
|
|
|
Script to be evaluated in all pages in the browser context. Optional.
|
|
|
|
|
|
|
|
### param: ElementHandle.selectOption.element = %%-python-select-options-element-%%
|
|
|
|
### param: ElementHandle.selectOption.index = %%-python-select-options-index-%%
|
|
|
|
### param: ElementHandle.selectOption.value = %%-python-select-options-value-%%
|
|
|
|
### param: ElementHandle.selectOption.label = %%-python-select-options-label-%%
|
|
|
|
|
|
|
|
### param: Frame.selectOption.element = %%-python-select-options-element-%%
|
|
|
|
### param: Frame.selectOption.index = %%-python-select-options-index-%%
|
|
|
|
### param: Frame.selectOption.value = %%-python-select-options-value-%%
|
|
|
|
### param: Frame.selectOption.label = %%-python-select-options-label-%%
|
|
|
|
|
|
|
|
### param: Page.selectOption.element = %%-python-select-options-element-%%
|
|
|
|
### param: Page.selectOption.index = %%-python-select-options-index-%%
|
|
|
|
### param: Page.selectOption.value = %%-python-select-options-value-%%
|
|
|
|
### param: Page.selectOption.label = %%-python-select-options-label-%%
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
### param: Page.emulateMedia.params
|
2021-01-07 23:37:53 -08:00
|
|
|
* langs: python
|
2021-01-10 18:18:35 -08:00
|
|
|
- `media` <[null]|"screen"|"print">
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`.
|
|
|
|
Passing `null` disables CSS media emulation. Omitting `media` or passing `undefined` does not change the emulated value.
|
|
|
|
Optional.
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
### param: Page.emulateMedia.params
|
2021-01-07 23:37:53 -08:00
|
|
|
* langs: python
|
2021-01-10 18:18:35 -08:00
|
|
|
- `colorScheme` <[null]|"light"|"dark"|"no-preference">
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
|
|
|
|
`null` disables color scheme emulation. Omitting `colorScheme` or passing `undefined` does not change the emulated
|
|
|
|
value. Optional.
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
### option: Page.frame.name
|
2021-01-07 23:37:53 -08:00
|
|
|
* langs: python
|
2021-01-10 18:18:35 -08:00
|
|
|
- `name` <[string]>
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
Frame name specified in the `iframe`'s `name` attribute. Optional.
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
### option: Page.frame.url
|
2021-01-07 23:37:53 -08:00
|
|
|
* langs: python
|
2021-01-10 18:18:35 -08:00
|
|
|
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
|
2021-01-07 23:37:53 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
A glob pattern, regex pattern or predicate receiving frame's `url` as a [URL] object. Optional.
|
2021-01-08 15:00:14 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
### option: Selectors.register.script
|
2021-01-08 15:00:14 -08:00
|
|
|
* langs: python
|
2021-01-10 18:18:35 -08:00
|
|
|
- `path` <[path]>
|
2021-01-08 15:00:14 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the current working directory.
|
2021-01-08 15:00:14 -08:00
|
|
|
|
2021-01-10 18:18:35 -08:00
|
|
|
### option: Selectors.register.script
|
2021-01-08 15:00:14 -08:00
|
|
|
* langs: python
|
2021-01-10 18:18:35 -08:00
|
|
|
- `script` <[string]>
|
|
|
|
|
|
|
|
Raw script content.
|
|
|
|
|
|
|
|
## method: Request.failure
|
|
|
|
* langs: python
|
|
|
|
- returns: <[null]|[string]>
|
|
|
|
|
|
|
|
Returns human-readable error message, e.g. `'net::ERR_FAILED'`. The method returns `None` unless this request has
|
|
|
|
failed, as reported by `requestfailed` event.
|
|
|
|
|
|
|
|
Example of logging of all the failed requests:
|
|
|
|
|
|
|
|
```python
|
|
|
|
page.on('requestfailed', lambda request: print(request.url + ' ' + request.failure);
|
|
|
|
```
|
|
|
|
|
|
|
|
## async method: Response.finished
|
|
|
|
* langs: python
|
|
|
|
- returns: <[null]|[string]>
|
|
|
|
|
|
|
|
Waits for this response to finish, returns failure error if request failed.
|
2021-01-08 15:00:14 -08:00
|
|
|
|
|
|
|
|
|
|
|
### option: BrowserContext.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
|
|
|
|
### option: BrowserContext.waitForEvent.timeout = %%-python-wait-for-event-timeout-%%
|
|
|
|
### option: Page.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
|
|
|
|
### option: Page.waitForEvent.timeout = %%-python-wait-for-event-timeout-%%
|
|
|
|
### option: WebSocket.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
|
|
|
|
### option: WebSocket.waitForEvent.timeout = %%-python-wait-for-event-timeout-%%
|
2021-01-08 16:17:54 -08:00
|
|
|
|
|
|
|
### param: ElementHandle.$eval.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: ElementHandle.$$eval.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Frame.$eval.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Frame.$$eval.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Frame.evaluate.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Frame.evaluateHandle.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Frame.waitForFunction.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: JSHandle.evaluate.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: JSHandle.evaluateHandle.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Page.$eval.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Page.$$eval.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Page.evaluate.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Page.evaluateHandle.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Page.waitForFunction.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Worker.evaluate.expression = %%-python-evaluate-expression-%%
|
|
|
|
### param: Worker.evaluateHandle.expression = %%-python-evaluate-expression-%%
|
|
|
|
|
|
|
|
### param: ElementHandle.$eval.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: ElementHandle.$$eval.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Frame.$eval.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Frame.$$eval.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Frame.evaluate.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Frame.evaluateHandle.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Frame.waitForFunction.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: JSHandle.evaluate.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: JSHandle.evaluateHandle.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Page.$eval.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Page.$$eval.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Page.evaluate.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Page.evaluateHandle.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Page.waitForFunction.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Worker.evaluate.expression = %%-python-evaluate-force-expression-%%
|
|
|
|
### param: Worker.evaluateHandle.expression = %%-python-evaluate-force-expression-%%
|