APIResponseAssertions
APIResponseAssertions 类提供了断言方法,可以用于对 APIResponse 进行断言。
// ...
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
public class TestPage {
// ...
@Test
void navigatesToLoginPage() {
// ...
APIResponse response = page.request().get("https://playwright.net.cn");
assertThat(response).isOK();
}
}
方法
isOK
添加于: v1.18确保响应状态码在 200..299 范围内。
用法
assertThat(response).isOK();
返回值
属性
not()
添加于: v1.20使断言检查相反的条件。例如,此代码测试响应状态是否不成功
assertThat(response).not().isOK();
用法
assertThat(response).not()
返回值