有没有一种简单的方法可以在wsl2上运行Puppeteer?我已经尝试了很多解决方案,也看了很多论坛来寻找答案。到目前为止还没有成功,我发现在windows上运行Puppeteer非常容易,但在wsl2上运行却非常困难。
我试过下载chrome和chrome,并指定executablePath
,但没有成功。
我知道它可以在我的Windows系统上工作,但似乎不能让Puppeteer在WSL2中运行。
我目前遇到此错误:
Timeout Error: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r1022525 is guaranteed to work.
我看node_modules的时候发现1022525版本正在使用中,我不知道人偶师的问题是什么,也不知道该怎么解决。
有人有什么想法吗?
1条答案
按热度按时间czfnxgou1#
As I do not see exactly what are you trying to do , in the moment I can think that this error accused because of your windows defender firewall, which do not allow access of your X-server.
anyway for me I use Puppeteer on wsl2 as following:
const puppeteer = require('puppeteer'); test('should create an element...etc', async () => { const browser = await puppeteer.launch({ headless: false, args: ['--window-size=1920,1080'] }); const page = await browser.newPage(); await page.goto( 'www.google.com' ); });
start the last code using (jest nameofyourtestfile) and your puppeteer will work as you like, Chromium will open in your windows ...enjoy...if there is any details which is not clear may you ask again. I hope that I helped