mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs(python): enable Python response assertions (#11609)
This commit is contained in:
parent
3c27badd31
commit
a13f71d328
@ -1,5 +1,5 @@
|
||||
# class: APIResponseAssertions
|
||||
* langs: js, java
|
||||
* langs: js, java, python
|
||||
|
||||
The [APIResponseAssertions] class provides assertion methods that can be used to make assertions about the [APIResponse] in the tests. A new instance of [APIResponseAssertions] is created by calling [`method: PlaywrightAssertions.expectAPIResponse`]:
|
||||
|
||||
@ -29,7 +29,6 @@ public class TestPage {
|
||||
```
|
||||
|
||||
```python async
|
||||
import re
|
||||
from playwright.async_api import Page, expect
|
||||
|
||||
async def test_navigates_to_login_page(page: Page) -> None:
|
||||
@ -39,7 +38,6 @@ async def test_navigates_to_login_page(page: Page) -> None:
|
||||
```
|
||||
|
||||
```python sync
|
||||
import re
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
def test_navigates_to_login_page(page: Page) -> None:
|
||||
@ -63,6 +61,11 @@ await expect(response).not.toBeOK();
|
||||
assertThat(response).not().isOK();
|
||||
```
|
||||
|
||||
## async method: APIResponseAssertions.NotToBeOK
|
||||
* langs: python
|
||||
|
||||
The opposite of [`method: APIResponseAssertions.toBeOK`].
|
||||
|
||||
## async method: APIResponseAssertions.toBeOK
|
||||
* langs:
|
||||
- alias-java: isOK
|
||||
@ -78,7 +81,6 @@ assertThat(response).isOK();
|
||||
```
|
||||
|
||||
```python async
|
||||
import re
|
||||
from playwright.async_api import expect
|
||||
|
||||
# ...
|
||||
|
||||
@ -55,7 +55,7 @@ reached. You can pass this timeout as an option.
|
||||
By default, the timeout for assertions is set to 5 seconds.
|
||||
|
||||
## method: PlaywrightAssertions.expectAPIResponse
|
||||
* langs: js, java
|
||||
* langs: js, java, python
|
||||
- alias-java: assertThat
|
||||
- alias-python: expect
|
||||
- alias-js: expect
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user