I'm doing a node aplication with Puppeteer and I need to set an Xvfb display as the main display for the browser, but i can't seem to find any way to do this. The closest I got to what I want is to use '--use-fake-device-for-media-stream', but I want to set as a real device instead of just a test video. There is anyway I can do this ?
CodePudding user response:
Puppeteer is headless (without a display) by nature, but you can set default viewports, pixel ratios, etc to simulate the devices you're testing against using page.emulate()
or page.setViewport()
.
CodePudding user response:
This solution has worked for me:
# install the package
apt-get install -y xvfb
# set display variable
export DISPLAY=:0
# start Xvfb daemon in the background (only once)
/usr/bin/Xvfb :0 -screen 0 1024x768x24 &
# wait a bit to let it come up (only once)
sleep 5
# add prefix "xvfb-run" to "node" or "python" script
xvfb-run node myscript.js
# or
xvfb-run python myscript.py
Don't forget to set { headless: false } when launching puppeteer.
Source: https://anti-captcha.com/apidoc/articles/how-to-integrate-the-plugin