Web Automation Testing with Playwright Java

HOME

<!-- https://mvnrepository.com/artifact/com.microsoft.playwright/playwright -->
<dependency>
    <groupId>com.microsoft.playwright</groupId>
    <artifactId>playwright</artifactId>
    <version>1.57.0</version>
</dependency>

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;

import java.util.regex.Pattern;

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

public class PlaywrightDemo {

    public static void main(String[] args) {

        try (Playwright playwright = Playwright.create()) {

            Browser browser = playwright.chromium().launch();
            Page page = browser.newPage();
            page.navigate("https://qaautomation.expert/");
            System.out.println("Title :" + page.title());
            assertThat(page).hasTitle(Pattern.compile("QA Automation Expert"));
        }
    }
}
  try (Playwright playwright = Playwright.create()) 
Browser browser = playwright.chromium().launch();
 Page page = browser.newPage();
page.navigate("https://qaautomation.expert/");
System.out.println("Title :" + page.title());
assertThat(page).hasTitle(Pattern.compile("QA Automation Expert"));