docs(python): fix outdated waitForResponse example (#5685)
This commit is contained in:
parent
28d9f244df
commit
2a6bb50425
|
|
@ -2950,15 +2950,29 @@ return finalResponse.ok();
|
||||||
```
|
```
|
||||||
|
|
||||||
```python async
|
```python async
|
||||||
first_response = await page.wait_for_response("https://example.com/resource")
|
async with page.expect_response("https://example.com/resource") as response_info:
|
||||||
final_response = await page.wait_for_response(lambda response: response.url == "https://example.com" and response.status === 200)
|
await page.click("input")
|
||||||
return final_response.ok
|
response = response_info.value
|
||||||
|
return response.ok
|
||||||
|
|
||||||
|
# or with a lambda
|
||||||
|
async with page.expect_response(lambda response: response.url == "https://example.com" and response.status === 200) as response_info:
|
||||||
|
await page.click("input")
|
||||||
|
response = response_info.value
|
||||||
|
return response.ok
|
||||||
```
|
```
|
||||||
|
|
||||||
```python sync
|
```python sync
|
||||||
first_response = page.wait_for_response("https://example.com/resource")
|
with page.expect_response("https://example.com/resource") as response_info:
|
||||||
final_response = page.wait_for_response(lambda response: response.url == "https://example.com" and response.status === 200)
|
page.click("input")
|
||||||
return final_response.ok
|
response = response_info.value
|
||||||
|
return response.ok
|
||||||
|
|
||||||
|
# or with a lambda
|
||||||
|
with page.expect_response(lambda response: response.url == "https://example.com" and response.status === 200) as response_info:
|
||||||
|
page.click("input")
|
||||||
|
response = response_info.value
|
||||||
|
return response.ok
|
||||||
```
|
```
|
||||||
|
|
||||||
### param: Page.waitForResponse.urlOrPredicate
|
### param: Page.waitForResponse.urlOrPredicate
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue