活动地址:CSDN21天学习挑战赛
在playwright安装中,如果没有输入 playwright install, 则不会安装浏览器,运行 playwright codegen 时会报浏览器找不到的错误:
"chromium" browser was not found.
Please complete Playwright installation via running
"python -m playwright install"
playwright 有自己管理浏览器的机制,最好不要绕过 playwright install 自己安装浏览器。playwright 下载好的浏览器会存放在本地一个特定的目录,当需要运行浏览器,会在这个目录下去查找有没有浏览器的可执行文件,如果没有找到,就会报上述错误。playwright 的浏览器默认会存放在以下目录:
windows:%USERPROFILE%AppDataLocalms-playwright
macos:~/Library/Caches/ms-playwright
linux:~/.cache/ms-playwright
通过 playwright install 安装浏览器很慢,它是从微软的 cdn 中下载的,经过实测,下载 firefox 浏览器用了 20 分钟。如果等不及,可以手工下载,把下载后的文件复制到数据目录下,目录的结构类似于这样。