Interface APIResponseAssertions
- All Known Implementing Classes:
APIResponseAssertionsImpl
public interface APIResponseAssertions
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();
}
}
-
Method Details
-
not
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();- Since:
- v1.20
-
isOK
void isOK()Ensures the response status code is within200..299range.**Usage**
assertThat(response).isOK();- Since:
- v1.18
-