在Eclipse中运行脚本时Playwright浏览器安装失败问题
解决Eclipse中Playwright浏览器安装失败(DNS解析错误)
错误核心问题
日志中反复出现getaddrinfo ENOTFOUND错误,说明本地无法解析Playwright浏览器包的下载域名(如playwright.azureedge.net),属于网络DNS解析或网络受限问题。
解决步骤
检查DNS设置:
手动执行ping playwright.azureedge.net,若无法解析,将系统DNS切换为公共DNS(如8.8.8.8、114.114.114.114)。Windows可在网络适配器属性中修改IPv4 DNS;Mac在网络设置中调整。配置代理(受限网络场景):
在Eclipse的运行配置中添加代理环境变量:
右键项目→Run As→Run Configurations→Environment标签,新增:HTTP_PROXY=http://代理地址:端口HTTPS_PROXY=http://代理地址:端口
手动下载浏览器包:
- 手动下载对应版本的Chromium包(日志中为Chromium 113.0.5672.53 win64版本)
- 解压到本地目录,通过代码指定路径:
Playwright playwright = Playwright.create(new Playwright.CreateOptions() .setChromiumPath("C:\\本地解压路径\\chrome.exe"));
或设置环境变量
PLAYWRIGHT_BROWSERS_PATH为解压目录,让Playwright自动识别。排查防火墙/安全软件:
暂时关闭本地防火墙、杀毒软件,或添加Playwright相关进程到白名单,避免网络请求被拦截。
原错误日志
Downloading Chromium 113.0.5672.53 (playwright build v1060)[2m from https://playwright.azureedge.net/builds/chromium/1060/chromium-win64.zip[22m Error: getaddrinfo ENOTFOUND playwright.azureedge.net at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:internal/dns/promises:95:17) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'playwright.azureedge.net' } Downloading Chromium 113.0.5672.53 (playwright build v1060)[2m from https://playwright-akamai.azureedge.net/builds/chromium/1060/chromium-win64.zip[22m Error: getaddrinfo ENOTFOUND playwright-akamai.azureedge.net at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:internal/dns/promises:95:17) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'playwright-akamai.azureedge.net' } Downloading Chromium 113.0.5672.53 (playwright build v1060)[2m from https://playwright-verizon.azureedge.net/builds/chromium/1060/chromium-win64.zip[22m Error: getaddrinfo ENOTFOUND playwright-verizon.azureedge.net at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:internal/dns/promises:95:17) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'playwright-verizon.azureedge.net' } Failed to install browsers Error: Failed to download Chromium 113.0.5672.53 (playwright build v1060), caused by Error: Download failure, code=1 at ChildProcess.<anonymous> (C:\Users\abhi\AppData\Local\Temp\playwright-java-2390916958096346510\package\lib\server\registry\browserFetcher.js:95:16) at ChildProcess.emit (node:events:513:28) at ChildProcess._handle.onexit (node:internal/child_process:291:12) Exception in thread "main" java.lang.RuntimeException: Failed to create driver at com.microsoft.playwright.impl.driver.Driver.createAndInstall(Driver.java:105) at com.microsoft.playwright.impl.driver.Driver.ensureDriverInstalled(Driver.java:57) at com.microsoft.playwright.impl.PlaywrightImpl.createImpl(PlaywrightImpl.java:45) at com.microsoft.playwright.impl.PlaywrightImpl.create(PlaywrightImpl.java:35) at com.microsoft.playwright.Playwright.create(Playwright.java:110) at com.microsoft.playwright.Playwright.create(Playwright.java:114) at PlayWright.Demo.App.main(App.java:11) Caused by: java.lang.RuntimeException: Failed to install browsers, exit code: 1 at com.microsoft.playwright.impl.driver.jar.DriverJar.installBrowsers(DriverJar.java:100) at com.microsoft.playwright.impl.driver.jar.DriverJar.initialize(DriverJar.java:69) at com.microsoft.playwright.impl.driver.Driver.initialize(Driver.java:64) at com.microsoft.playwright.impl.driver.Driver.createAndInstall(Driver.java:101) ... 6 more
错误截图

内容的提问来源于stack exchange,提问作者Arun
相关产品推荐
相关产品推荐

