playwright java刷缓存

370 阅读1分钟
import com.microsoft.playwright.*;

public class ClearCacheExample {
    public static void main(String[] args) {
        try (Playwright playwright = Playwright.create()) {
            // Create a new browser context with temporary profile directory
            Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setArgs(new String[]{"--user-data-dir=tmp_profile"}));
            BrowserContext context = browser.newContext();

            // Perform your actions and load pages in the browser context

            // Close the browser
            browser.close();
        }
    }
}