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 Summary

    Modifier and Type
    Method
    Description
    void
    Ensures the response status code is within 200..299 range.
    not()
    Makes the assertion check for the opposite condition.
  • Method Details

    • 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 within 200..299 range.

      **Usage**

      
       assertThat(response).isOK();
       
      Since:
      v1.18