メインコンテンツにスキップ

APIResponseAssertions

APIResponseAssertions クラスは、テストで APIResponse に関するアサーションを行うために使用できるアサーションメソッドを提供します。

// ...
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;

public class TestPage {
// ...
@Test
void navigatesToLoginPage() {
// ...
APIResponse response = page.request().get("https://playwright.dokyumento.jp");
assertThat(response).isOK();
}
}

メソッド

isOK

追加: v1.18 apiResponseAssertions.isOK

レスポンスステータスコードが 200..299 の範囲内であることを保証します。

使用例

assertThat(response).isOK();

戻り値


プロパティ

not()

追加: v1.20 apiResponseAssertions.not()

アサーションが反対の条件をチェックするようにします。たとえば、このコードはレスポンスステータスが成功ではないことをテストします。

assertThat(response).not().isOK();

使用例

assertThat(response).not()

戻り値