File: class-apiresponseassertions.md | Updated: 11/18/2025
On this page
The APIResponseAssertions class provides assertion methods that can be used to make assertions about the APIResponse in the tests.
// ...import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;public class TestPage { // ... @Test void navigatesToLoginPage() { // ... APIResponse response = page.request().get("https://playwright.dev"); assertThat(response).isOK(); }}
Methods
Added in: v1.18 apiResponseAssertions.isOK
Ensures the response status code is within 200..299 range.
Usage
assertThat(response).isOK();
Returns
Properties
Added in: v1.20 apiResponseAssertions.not()
Makes the assertion check for the opposite condition. For example, this code tests that the response status is not successful:
assertThat(response).not().isOK();
Usage
assertThat(response).not()
Returns