Playwright 断言我觉得好的地方就是。Playwright会检查并且自动重试,直到满足我所设置的断言的必要条件。Playwright 的自动等待功能,会在执行操作之前等待元素可操作。Playwright 使用assertThat重载来进行断言。
下面的示例测试,了解如何使用 Web 优先断言、定位器和选择器编写测试。
package org.example;
import java.util.regex.Pattern;
import com.microsoft.playwright.*;
import com.microsoft.playwright.options.AriaRole;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
public class App {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();