4 ms·
This is the way I am going. I spent a long time trying to find an up to date javascript engine in a headless browser a while back before I gave up and just wro
by c0nfused 10y ago
This is the way I am going.
I spent a long time trying to find an up to date javascript engine in a headless browser a while back before I gave up and just wrote a chrome extension, installed a copy of chromium, and ran the whole thing in xvfb with the extension added by command line.
In the end unless you are severely resource constrained,it is a very good option.
- chriswarbo 10y agoI've done a similar thing. There are annoyances with both XVFB and Firefox instances clobbering each other though. For XVFB, each instance needs a globally unique display number. For Firefox, you need the "-new-instance" or "-no-remote" option, along with a unique profile (e.g. in a temp dir).
- jordanpg 10y agoCould you say more about what you mean by "clobbering each other" here? I run firefox/chrome under Xvfb and very frequently get unexplaine `Unable to connect to host 127.0.0.1 on port 7055` from selenium, zombie firefox and chrome processes, and hundreds of TCP ports in status TIME_WAIT. I've always assumed it had something to do with Xvfb/browser interaction.
- j_s 10y agoFirefox shares sessions (cookies, etc.) between all running instances by default.
- chriswarbo 10y agoWhen you run "firefox", it will check if the current user already has an instance running; even if it's on a different display. To prevent that you need to run the firefox command with "-new-instance" or "-no-remote" (which implies "-new-instance"). Firefox also 'locks' profiles which are in use, so you need to use separate profiles for each Firefox instance which is running. You can do that by making a temporary directory "T" and passing it to the firefox command as "-profile T". As an example, the Firefox command I'm using in one of my scripts is currently: timeout 60 firefox -safe-mode \ -profile "$FF_DIR" \ -no-remote \ -new-instance \ "$URL" XFVB is an X server, which programs connect to based on the "DISPLAY" environment variable. You can see what that's set to by running: echo "$DISPLAY" You can set it, e.g. to ":99", by doing: export DISPLAY=:99 Each running X server needs a different display number; this includes regular desktop sessions (usually running on Xorg with display :0), XVFB, Xnest, Xephyr, etc. I use a variant of the script at http://stackoverflow.com/a/30336424/884682 http://stackoverflow.com/a/30336424/884682 to choose an unused display number for each XVFB invocation. NOTE: This is based on simple automation tasks with bash and xdotool. I don't use Selenium, so I don't know if already does any of this. Hope it helps anyway :)