docs: allow overriding return types (#5031)
This commit is contained in:
parent
940cf35d84
commit
41e394bc22
|
|
@ -567,7 +567,7 @@ await browser.close();
|
|||
```python async
|
||||
context = await browser.new_context()
|
||||
page = await context.new_page()
|
||||
await context.route(r"(\.png$)|(\.jpg$)", lambda route: route.abort())
|
||||
await context.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())
|
||||
page = await context.new_page()
|
||||
await page.goto("https://example.com")
|
||||
await browser.close()
|
||||
|
|
@ -576,7 +576,7 @@ await browser.close()
|
|||
```python sync
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
context.route(r"(\.png$)|(\.jpg$)", lambda route: route.abort())
|
||||
context.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())
|
||||
page = await context.new_page()
|
||||
page = context.new_page()
|
||||
page.goto("https://example.com")
|
||||
|
|
@ -736,24 +736,30 @@ A glob pattern, regex pattern or predicate receiving [URL] used to register a ro
|
|||
Optional handler function used to register a routing with [`method: BrowserContext.route`].
|
||||
|
||||
## async method: BrowserContext.waitForEvent
|
||||
* langs:
|
||||
- alias-python: expect_event
|
||||
- returns: <[any]>
|
||||
|
||||
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
|
||||
value. Will throw an error if the context closes before the event is fired. Returns the event data value.
|
||||
|
||||
```js
|
||||
const context = await browser.newContext();
|
||||
await context.grantPermissions(['geolocation']);
|
||||
const [page, _] = await Promise.all([
|
||||
context.waitForEvent('page'),
|
||||
page.click('button')
|
||||
]);
|
||||
```
|
||||
|
||||
```python async
|
||||
context = await browser.new_context()
|
||||
await context.grant_permissions(["geolocation"])
|
||||
async with context.expect_event("page") as event_info:
|
||||
await page.click("button")
|
||||
page = await event_info.value
|
||||
```
|
||||
|
||||
```python sync
|
||||
context = browser.new_context()
|
||||
context.grant_permissions(["geolocation"])
|
||||
with context.expect_event("page") as event_info:
|
||||
page.click("button")
|
||||
page = event_info.value
|
||||
```
|
||||
|
||||
### param: BrowserContext.waitForEvent.event
|
||||
|
|
|
|||
|
|
@ -1135,11 +1135,13 @@ frame.wait_for_load_state() # the promise resolves after "load" event.
|
|||
### option: Frame.waitForLoadState.timeout = %%-navigation-timeout-%%
|
||||
|
||||
## async method: Frame.waitForNavigation
|
||||
* langs:
|
||||
* alias-python: expect_navigation
|
||||
- returns: <[null]|[Response]>
|
||||
|
||||
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
||||
last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
|
||||
resolve with `null`.
|
||||
Waits for the frame navigation and returns the main resource response. In case of multiple redirects, the navigation
|
||||
will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to
|
||||
History API usage, the navigation will resolve with `null`.
|
||||
|
||||
This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
|
||||
the frame to navigate. Consider this example:
|
||||
|
|
|
|||
|
|
@ -1783,14 +1783,14 @@ await browser.close();
|
|||
|
||||
```python async
|
||||
page = await browser.new_page()
|
||||
await page.route(r"(\.png$)|(\.jpg$)", lambda route: route.abort())
|
||||
await page.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())
|
||||
await page.goto("https://example.com")
|
||||
await browser.close()
|
||||
```
|
||||
|
||||
```python sync
|
||||
page = browser.new_page()
|
||||
page.route(r"(\.png$)|(\.jpg$)", lambda route: route.abort())
|
||||
page.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())
|
||||
page.goto("https://example.com")
|
||||
browser.close()
|
||||
```
|
||||
|
|
@ -2163,12 +2163,31 @@ Video object associated with this page.
|
|||
- `height` <[int]> page height in pixels.
|
||||
|
||||
## async method: Page.waitForEvent
|
||||
* langs:
|
||||
- alias-python: expect_event
|
||||
- returns: <[any]>
|
||||
|
||||
Returns the event data value.
|
||||
|
||||
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
|
||||
value. Will throw an error if the page is closed before the event is fired.
|
||||
value. Will throw an error if the page is closed before the event is fired. Returns the event data value.
|
||||
|
||||
```js
|
||||
const [frame, _] = await Promise.all([
|
||||
page.waitForEvent('framenavigated'),
|
||||
page.click('button')
|
||||
]);
|
||||
```
|
||||
|
||||
```python async
|
||||
async with page.expect_event("framenavigated") as event_info:
|
||||
await page.click("button")
|
||||
frame = await event_info.value
|
||||
```
|
||||
|
||||
```python sync
|
||||
with page.expect_event("framenavigated") as event_info:
|
||||
page.click("button")
|
||||
frame = event_info.value
|
||||
```
|
||||
|
||||
### param: Page.waitForEvent.event = %%-wait-for-event-event-%%
|
||||
|
||||
|
|
@ -2329,11 +2348,13 @@ Shortcut for main frame's [`method: Frame.waitForLoadState`].
|
|||
### option: Page.waitForLoadState.timeout = %%-navigation-timeout-%%
|
||||
|
||||
## async method: Page.waitForNavigation
|
||||
* langs:
|
||||
* alias-python: expect_navigation
|
||||
- returns: <[null]|[Response]>
|
||||
|
||||
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
||||
last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
|
||||
resolve with `null`.
|
||||
Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the navigation
|
||||
will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to
|
||||
History API usage, the navigation will resolve with `null`.
|
||||
|
||||
This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly
|
||||
cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`.
|
||||
|
|
@ -2372,6 +2393,8 @@ Shortcut for main frame's [`method: Frame.waitForNavigation`].
|
|||
### option: Page.waitForNavigation.waitUntil = %%-navigation-wait-until-%%
|
||||
|
||||
## async method: Page.waitForRequest
|
||||
* langs:
|
||||
* alias-python: expect_request
|
||||
- returns: <[Request]>
|
||||
|
||||
Waits for the matching request and returns it.
|
||||
|
|
@ -2383,15 +2406,23 @@ return firstRequest.url();
|
|||
```
|
||||
|
||||
```python async
|
||||
first_request = await page.wait_for_request("http://example.com/resource")
|
||||
final_request = await page.wait_for_request(lambda request: request.url == "http://example.com" and request.method == "get")
|
||||
return first_request.url
|
||||
async with page.expect_request("http://example.com/resource") as first:
|
||||
await page.click('button')
|
||||
first_request = await first.value
|
||||
|
||||
async with page.expect_request(lambda request: request.url == "http://example.com" and request.method == "get") as second:
|
||||
await page.click('img')
|
||||
second_request = await second.value
|
||||
```
|
||||
|
||||
```python sync
|
||||
first_request = page.wait_for_request("http://example.com/resource")
|
||||
final_request = page.wait_for_request(lambda request: request.url == "http://example.com" and request.method == "get")
|
||||
return first_request.url
|
||||
with page.expect_request("http://example.com/resource") as first:
|
||||
page.click('button')
|
||||
first_request = first.value
|
||||
|
||||
with page.expect_request(lambda request: request.url == "http://example.com" and request.method == "get") as second:
|
||||
page.click('img')
|
||||
second_request = second.value
|
||||
```
|
||||
|
||||
```js
|
||||
|
|
@ -2410,6 +2441,8 @@ Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable t
|
|||
changed by using the [`method: Page.setDefaultTimeout`] method.
|
||||
|
||||
## async method: Page.waitForResponse
|
||||
* langs:
|
||||
* alias-python: expect_response
|
||||
- returns: <[Response]>
|
||||
|
||||
Returns the matched response.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ If request gets a 'redirect' response, the request is successfully finished with
|
|||
request is issued to a redirected url.
|
||||
|
||||
## method: Request.failure
|
||||
* langs: js
|
||||
- returns: <[null]|[Object]>
|
||||
- `errorText` <[string]> Human-readable error message, e.g. `'net::ERR_FAILED'`.
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
Returns the buffer with response body.
|
||||
|
||||
## async method: Response.finished
|
||||
* langs: js
|
||||
- returns: <[null]|[Error]>
|
||||
|
||||
Waits for this response to finish, returns failure error if request failed.
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ Indicates that the web socket has been closed.
|
|||
Contains the URL of the WebSocket.
|
||||
|
||||
## async method: WebSocket.waitForEvent
|
||||
* langs:
|
||||
- alias-python: expect_event
|
||||
- returns: <[any]>
|
||||
|
||||
Returns the event data value.
|
||||
|
||||
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
|
||||
value. Will throw an error if the webSocket is closed before the event is fired.
|
||||
value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
|
||||
|
||||
### param: WebSocket.waitForEvent.event
|
||||
- `event` <[string]>
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
## async method: Playwright.start
|
||||
* langs: python
|
||||
|
||||
Starts a new instance of Playwright without using the Python context manager. This is useful in REPL applications. Requires [`method: Playwright.stop`] to be called to cleanup resources.
|
||||
|
||||
```py
|
||||
>>> from playwright.sync_api 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()
|
||||
```
|
||||
|
||||
## async method: Playwright.stop
|
||||
* langs: python
|
||||
|
||||
|
|
@ -120,160 +101,27 @@ Raw script content.
|
|||
* 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:
|
||||
|
||||
```py
|
||||
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.
|
||||
|
||||
## async method: Page.expectEvent
|
||||
## async method: Page.waitForEvent
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]>
|
||||
### option: Page.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: Page.waitForEvent.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
Performs action and waits for given `event` to fire. If predicate is provided, it passes
|
||||
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if the page is closed before the `event` is fired.
|
||||
|
||||
```python async
|
||||
async with page.expect_event(event_name) as event_info:
|
||||
await page.click("button")
|
||||
value = await event_info.value
|
||||
```
|
||||
|
||||
```python sync
|
||||
with page.expect_event(event_name) as event_info:
|
||||
page.click("button")
|
||||
value = event_info.value
|
||||
```
|
||||
|
||||
### param: Page.expectEvent.event = %%-wait-for-event-event-%%
|
||||
### option: Page.expectEvent.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: Page.expectEvent.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
## async method: BrowserContext.expectEvent
|
||||
## async method: BrowserContext.waitForEvent
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]>
|
||||
### option: BrowserContext.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: BrowserContext.waitForEvent.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
Performs action and waits for given `event` to fire. If predicate is provided, it passes
|
||||
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if browser context is closed before the `event` is fired.
|
||||
|
||||
```python async
|
||||
async with context.expect_event("page") as event_info:
|
||||
await context.click("button")
|
||||
page = await event_info.value
|
||||
```
|
||||
|
||||
```python sync
|
||||
with context.expect_event("page") as event_info:
|
||||
context.click("button")
|
||||
page = event_info.value
|
||||
```
|
||||
|
||||
### param: BrowserContext.expectEvent.event = %%-wait-for-event-event-%%
|
||||
### option: BrowserContext.expectEvent.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: BrowserContext.expectEvent.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
## async method: WebSocket.expectEvent
|
||||
## async method: WebSocket.waitForEvent
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]>
|
||||
|
||||
Performs action and waits for given `event` to fire. If predicate is provided, it passes
|
||||
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if the socket is closed before the `event` is fired.
|
||||
|
||||
```python async
|
||||
async with ws.expect_event(event_name) as event_info:
|
||||
await ws.click("button")
|
||||
value = await event_info.value
|
||||
```
|
||||
|
||||
```python sync
|
||||
with ws.expect_event(event_name) as event_info:
|
||||
ws.click("button")
|
||||
value = event_info.value
|
||||
```
|
||||
|
||||
### param: WebSocket.expectEvent.event = %%-wait-for-event-event-%%
|
||||
### option: WebSocket.expectEvent.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: WebSocket.expectEvent.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
## async method: Page.expectNavigation
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]>
|
||||
|
||||
Performs action and waits for the next navigation. In case of multiple redirects, the navigation will resolve with
|
||||
the response of the last redirect. In case of navigation to a different anchor or navigation due to History API
|
||||
usage, the navigation will resolve with `null`.
|
||||
|
||||
This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will
|
||||
indirectly cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation
|
||||
from a `setTimeout`. Consider this example:
|
||||
|
||||
```python async
|
||||
async with page.expect_navigation():
|
||||
await page.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
|
||||
# Context manager waited for the navigation to happen.
|
||||
```
|
||||
|
||||
```python sync
|
||||
with page.expect_navigation():
|
||||
page.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
|
||||
# Context manager waited for the navigation to happen.
|
||||
```
|
||||
|
||||
:::note
|
||||
Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.
|
||||
:::
|
||||
|
||||
Shortcut for main frame's [`method: Frame.expectNavigation`].
|
||||
|
||||
### option: Page.expectNavigation.timeout = %%-navigation-timeout-%%
|
||||
### option: Page.expectNavigation.url = %%-wait-for-navigation-url-%%
|
||||
### option: Page.expectNavigation.waitUntil = %%-navigation-wait-until-%%
|
||||
|
||||
## async method: Frame.expectNavigation
|
||||
* langs: python
|
||||
- returns: <[EventContextManager[Response]]>
|
||||
|
||||
Performs action and waits for the next navigation. In case of multiple redirects, the navigation will resolve with
|
||||
the response of the last redirect. In case of navigation to a different anchor or navigation due to History API
|
||||
usage, the navigation will resolve with `null`.
|
||||
|
||||
This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will
|
||||
indirectly cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation
|
||||
from a `setTimeout`. Consider this example:
|
||||
|
||||
```python async
|
||||
async with frame.expect_navigation():
|
||||
await frame.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
|
||||
# Context manager waited for the navigation to happen.
|
||||
```
|
||||
|
||||
```python sync
|
||||
with frame.expect_navigation():
|
||||
frame.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
|
||||
# Context manager waited for the navigation to happen.
|
||||
```
|
||||
|
||||
:::note
|
||||
Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the
|
||||
URL is considered a navigation.
|
||||
:::
|
||||
|
||||
### option: Frame.expectNavigation.timeout = %%-navigation-timeout-%%
|
||||
### option: Frame.expectNavigation.url = %%-wait-for-navigation-url-%%
|
||||
### option: Frame.expectNavigation.waitUntil = %%-navigation-wait-until-%%
|
||||
|
||||
### option: WebSocket.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: WebSocket.waitForEvent.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
## async method: Page.expectDownload
|
||||
* langs: python
|
||||
|
|
@ -376,46 +224,72 @@ Receives the [Page] object and resolves to truthy value when the waiting should
|
|||
|
||||
### option: BrowserContext.expectPage.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
|
||||
## async method: Page.expectRequest
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]<[Request]>>
|
||||
|
||||
Performs action and waits for `response` event to fire. If predicate is provided, it passes
|
||||
[Request] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if the page is closed before the download event is fired.
|
||||
|
||||
### param: Page.expectRequest.url_or_predicate =
|
||||
* langs: python
|
||||
- `url_or_predicate` <[str]|[RegExp]|[function]\([Request]\):[bool]>
|
||||
|
||||
Receives the [Request] object and resolves to truthy value when the waiting should resolve.
|
||||
|
||||
### option: Page.expectRequest.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
## async method: Page.expectResponse
|
||||
## async method: Frame.waitForNavigation
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]<[Response]>>
|
||||
|
||||
Performs action and waits for `response` event to fire. If predicate is provided, it passes
|
||||
[Response] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if the page is closed before the download event is fired.
|
||||
|
||||
### param: Page.expectResponse.url_or_predicate =
|
||||
## async method: Page.waitForNavigation
|
||||
* langs: python
|
||||
- `url_or_predicate` <[str]|[RegExp]|[function]\([Response]\):[bool]>
|
||||
- returns: <[EventContextManager]<[Response]>>
|
||||
|
||||
Receives the [Response] object and resolves to truthy value when the waiting should resolve.
|
||||
## async method: Page.waitForRequest
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]<[Request]>>
|
||||
|
||||
### option: Page.expectResponse.timeout = %%-python-wait-for-event-timeout-%%
|
||||
## async method: Page.waitForResponse
|
||||
* langs: python
|
||||
- returns: <[EventContextManager]<[Response]>>
|
||||
|
||||
## async method: BrowserContext.waitForEvent2
|
||||
* langs: python
|
||||
- alias-python: wait_for_event
|
||||
- returns: <[Any]>
|
||||
|
||||
### 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-%%
|
||||
:::note
|
||||
In most cases, you should use [`method: BrowserContext.waitForEvent`].
|
||||
:::
|
||||
|
||||
Waits for given `event` to fire. If predicate is provided, it passes
|
||||
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if the socket is closed before the `event` is fired.
|
||||
|
||||
### param: BrowserContext.waitForEvent2.event = %%-wait-for-event-event-%%
|
||||
### option: BrowserContext.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: BrowserContext.waitForEvent2.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
## async method: Page.waitForEvent2
|
||||
* langs: python
|
||||
- alias-python: wait_for_event
|
||||
- returns: <[Any]>
|
||||
|
||||
:::note
|
||||
In most cases, you should use [`method: Page.waitForEvent`].
|
||||
:::
|
||||
|
||||
Waits for given `event` to fire. If predicate is provided, it passes
|
||||
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if the socket is closed before the `event` is fired.
|
||||
|
||||
### param: Page.waitForEvent2.event = %%-wait-for-event-event-%%
|
||||
### option: Page.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: Page.waitForEvent2.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
## async method: WebSocket.waitForEvent2
|
||||
* langs: python
|
||||
- alias-python: wait_for_event
|
||||
- returns: <[Any]>
|
||||
|
||||
:::note
|
||||
In most cases, you should use [`method: WebSocket.waitForEvent`].
|
||||
:::
|
||||
|
||||
Waits for given `event` to fire. If predicate is provided, it passes
|
||||
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
||||
Will throw an error if the socket is closed before the `event` is fired.
|
||||
|
||||
### param: WebSocket.waitForEvent2.event = %%-wait-for-event-event-%%
|
||||
### option: WebSocket.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%%
|
||||
### option: WebSocket.waitForEvent2.timeout = %%-python-wait-for-event-timeout-%%
|
||||
|
||||
### param: ElementHandle.$eval.expression = %%-python-evaluate-expression-%%
|
||||
### param: ElementHandle.$$eval.expression = %%-python-evaluate-expression-%%
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ page.fill("#username", "John Doe")
|
|||
|
||||
### Asynchronous navigation
|
||||
|
||||
Clicking an element could trigger asychronous processing before initiating the navigation. In these cases, it is
|
||||
Clicking an element could trigger asynchronous processing before initiating the navigation. In these cases, it is
|
||||
recommended to explicitly call [`method: Page.waitForNavigation`]. For example:
|
||||
* Navigation is triggered from a `setTimeout`
|
||||
* Page waits for network requests before navigation
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ const [response] = await Promise.all([
|
|||
```
|
||||
|
||||
```python async
|
||||
# Use a regular expresison
|
||||
# Use a regular expression
|
||||
async with page.expect_response(re.compile(r"\.jpeg$")) as response_info:
|
||||
await page.click("button#update")
|
||||
response = await response_info.value
|
||||
|
|
@ -217,7 +217,7 @@ response = await response_info.value
|
|||
```
|
||||
|
||||
```python sync
|
||||
# Use a regular expresison
|
||||
# Use a regular expression
|
||||
with page.expect_response(re.compile(r"\.jpeg$")) as response_info:
|
||||
page.click("button#update")
|
||||
response = response_info.value
|
||||
|
|
|
|||
12
types/types.d.ts
vendored
12
types/types.d.ts
vendored
|
|
@ -3051,9 +3051,9 @@ export interface Page {
|
|||
}): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
||||
* last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
|
||||
* resolve with `null`.
|
||||
* Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the
|
||||
* navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or
|
||||
* navigation due to History API usage, the navigation will resolve with `null`.
|
||||
*
|
||||
* This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly
|
||||
* cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`.
|
||||
|
|
@ -4431,9 +4431,9 @@ export interface Frame {
|
|||
}): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
||||
* last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will
|
||||
* resolve with `null`.
|
||||
* Waits for the frame navigation and returns the main resource response. In case of multiple redirects, the navigation
|
||||
* will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to
|
||||
* History API usage, the navigation will resolve with `null`.
|
||||
*
|
||||
* This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause
|
||||
* the frame to navigate. Consider this example:
|
||||
|
|
|
|||
|
|
@ -99,7 +99,15 @@ class ApiParser {
|
|||
member.async = true;
|
||||
}
|
||||
const clazz = this.classes.get(match[2]);
|
||||
clazz.membersArray.push(member);
|
||||
const existingMember = clazz.membersArray.find(m => m.name === name && m.kind === "method");
|
||||
if (existingMember) {
|
||||
for (const lang of member.langs.only) {
|
||||
existingMember.langs.types = existingMember.langs.types || {};
|
||||
existingMember.langs.types[lang] = returnType;
|
||||
}
|
||||
} else {
|
||||
clazz.membersArray.push(member);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -293,7 +301,8 @@ function extractLangs(spec) {
|
|||
}
|
||||
return {
|
||||
only: only ? only.split(',') : undefined,
|
||||
aliases
|
||||
aliases,
|
||||
types: {}
|
||||
};
|
||||
}
|
||||
return {};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ const md = require('../markdown');
|
|||
/**
|
||||
* @typedef {{
|
||||
* only?: string[],
|
||||
* aliases?: Object<string, string>
|
||||
* aliases?: Object<string, string>,
|
||||
* types?: Object<string, Documentation.Type>,
|
||||
* }} Langs
|
||||
*/
|
||||
|
||||
|
|
@ -197,8 +198,6 @@ Documentation.Class = class {
|
|||
for (const member of this.membersArray) {
|
||||
if (member.langs.only && !member.langs.only.includes(lang))
|
||||
continue;
|
||||
if (member.langs.aliases && member.langs.aliases[lang])
|
||||
member.alias = member.langs.aliases[lang];
|
||||
member.filterForLanguage(lang);
|
||||
membersArray.push(member);
|
||||
}
|
||||
|
|
@ -312,6 +311,11 @@ Documentation.Member = class {
|
|||
* @param {string} lang
|
||||
*/
|
||||
filterForLanguage(lang) {
|
||||
if (this.langs.aliases && this.langs.aliases[lang])
|
||||
this.alias = this.langs.aliases[lang];
|
||||
if (this.langs.types && this.langs.types[lang])
|
||||
this.type = this.langs.types[lang];
|
||||
this.type.filterForLanguage(lang);
|
||||
const argsArray = [];
|
||||
for (const arg of this.argsArray) {
|
||||
if (arg.langs.only && !arg.langs.only.includes(lang))
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ function serializeClass(clazz) {
|
|||
if (clazz.extends)
|
||||
result.extends = clazz.extends;
|
||||
result.langs = clazz.langs;
|
||||
if (result.langs && result.langs.types) {
|
||||
for (const key in result.langs.types)
|
||||
result.langs.types[key] = serializeType(result.langs.types[key]);
|
||||
}
|
||||
if (clazz.comment)
|
||||
result.comment = clazz.comment;
|
||||
result.members = clazz.membersArray.map(serializeMember);
|
||||
|
|
|
|||
Loading…
Reference in a new issue