Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: make toBeOK async, expose in java (#11227)

Yury Semikhatskyd629fe57abed
diff --git a/docs/src/api/class-apiresponseassertions.md b/docs/src/api/class-apiresponseassertions.md
index e83076048c..57a21aa97d 100644
--- a/docs/src/api/class-apiresponseassertions.md
+++ b/docs/src/api/class-apiresponseassertions.md
@@ -1,5 +1,5 @@
# class: APIResponseAssertions
-* langs: js
+* langs: js, java
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`]:
@@ -9,7 +9,7 @@ import { test, expect } from '@playwright/test';
test('navigates to login', async ({ page }) => {
// ...
const response = await page.request.get('https://playwright.dev');
- expect(response).toBeOK();
+ await expect(response).toBeOK();
});
```
@@ -35,7 +35,7 @@ from playwright.async_api import Page, expect
async def test_navigates_to_login_page(page: Page) -> None:
# ..
response = await page.request.get('https://playwright.dev')
- expect(response).to_be_ok()
+ await expect(response).to_be_ok()
```
```python sync
@@ -56,21 +56,21 @@ def test_navigates_to_login_page(page: Page) -> None:
Makes the assertion check for the opposite condition. For example, this code tests that the response status is not successfull:
```js
-expect(response).not.toBeOK();
+await expect(response).not.toBeOK();
```
```java
assertThat(response).not().isOK();
```
-## method: APIResponseAssertions.toBeOK
+## async method: APIResponseAssertions.toBeOK
* langs:
- alias-java: isOK
Ensures the response status code is within [200..299) range.
```js
-expect(response).toBeOK();
+await expect(response).toBeOK();
```
```java
@@ -82,7 +82,7 @@ import re
from playwright.async_api import expect
# ...
-expect(response).to_be_ok()
+await expect(response).to_be_ok()
```
```python sync
diff --git a/docs/src/api/class-playwrightassertions.md b/docs/src/api/class-playwrightassertions.md
index 3c9c226bc7..778a3f09a3 100644
--- a/docs/src/api/class-playwrightassertions.md
+++ b/docs/src/api/class-playwrightassertions.md
@@ -65,7 +65,7 @@ By default, the timeout for assertions is set to 5 seconds.
```
## method: PlaywrightAssertions.expectAPIResponse
-* langs: js
+* langs: js, java
- alias-java: assertThat
- alias-python: expect
- alias-js: expect