第一次接触playwright,系统是win10,使用playwright要下载chromium,应该是权限问题,即使使用管理员权限执行命令:playwright install chromium,最后还是会报错:

Downloading Chromium 108.0.5359.29 (playwright build v1033) from https://playwright.azureedge.net/builds/chromium/1033/chromium-win64.zip
109.5 Mb [====================] 100% 0.0s
Failed to install browsers
Error: Failed to download Chromium 108.0.5359.29 (playwright build v1033), caused by
Error: EPERM: operation not permitted, open 'C:\Users\用户名\AppData\Local\ms-playwright\chromium-1033\chrome-win\chrome_elf.dll'

大概意思就是权限不够,所以最后下载的chromium文件是不全的,在使用playwright就会报错,找不到chrome_elf.dll这个文件,因为从始至终,这个文件就没有成功下载,最开始从网上下了个最新的chrome_elf.dll文件,放到对应文件夹下,还是会报错。后来发现当前下载的playwright版本是1.28.0,对应的chromium版本是108.0.5359.29,最后是从这里下载到了对应版本的chromium,将下载的zip文件解压后,放到C:\Users\用户名\AppData\Local\ms-playwright\chromium-1033即可正常使用playwright了。写这些文字的时候才发现,根本不用费劲去找对应的chromium版本,报错里的链接https://playwright.azureedge.net/builds/chromium/1033/chromium-win64.zip,直接给出了下载地址,只要用浏览器下载后放到对应的文件夹内即可。。。。。。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐