Playwright基本配置
2025 年 10 月 10 日 • 开发
这篇文章主要介绍了如何使用Playwright库在Java中进行浏览器自动化测试。
使用本地配置,跳过开始自动下载
java
复制代码
Playwright.CreateOptions options = new Playwright.CreateOptions();
HashMap<String, String> map = new HashMap<>();
map.put("PLAYWRIGHT_BROWSERS_PATH", "/Users/Desktop/");
map.put("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "1");
options.setEnv(map);
Playwright playwright = Playwright.create(options);
使用本地代理
java
复制代码
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setProxy(new Proxy("http://10.0.1.1:7890")).setHeadless(false));
留言 (0)