I recently had to deal with WebRTC on a headless machine and managed to hack up something with some Python scripting and GStreamer. I didn't know it was possible to run Firefox headlessly and now you got me wondering whether that would have been preferable to my stitched up solution.
Instead of having a real screen, Xvfb uses an in-memory framebuffer for screen output that you can screenshot etc if needed.
It's as easy as:
Xvfb :123 &
DISPLAY=:123 firefox
### firefox is now running and outputting
### to the framebuffer display on :123, and
### can be driven by WebDriver etc. xvfb-run --auto-servernum --server-args="-screen 0, 1024x868x24" firefoxXvfb looks to be pretty straightforward about what it does; now I just need to figure out how to control firefox after it was started.
1. It use javascript to script so writting sequential code wasn't possible so the code ended up using continuation passing style.
2. The very first example snippet on the front page don't work in the repl (https://github.com/ariya/phantomjs/issues/11180). So the repl is useless.
3. When an error occur in your script (not the one on the webpage) there is no message anywhere no matter what you do.
My mistake was to continue with phantomjs the hype around made me think others options would have been worst.
I have used selenium+firefox+php to do a quick test it was wayyyy better, just for n°1 using sequential php remove a lot headaches.
Near the top of a google search for 'phantomjs vs selenium', we have folks on HN complaining about phantomjs https://news.ycombinator.com/item?id=8418071