What's a simple way to launch a browser on an server that doesn't have a GUI, but needs a GUI-like browser? Something like Firefox or Chrome. I need to trigger a page load but it needs full javascript support. Once the page is loaded it can close out. But otherwise I have no need for a full graphical interface.

  • 1
    Is X forwarding an option? This executes the browser on the server but displays it on a different machine.
    – Marco
    May 10 '13 at 9:13

There are two options I can recommend here:

First, if you want to literally launch a full graphical browser and have it load a page with on a machine with no graphical capabilities, there is a tool called xvfb that will let you run a complete X server with no physical display associated with it. You then just need to run firefox with that X server set as the DISPLAY environment variable, and pass the URL you want to open as an argument on the command line. There is a comprehensive tutorial here, geared specifically towards doing this in an automated testing setting.

For your use case, however, it might be simpler to leverage phantom.js, which is a full webkit implementation designed specifically to run in a headless/non-graphical environment and offering a javascript API.

  • Thank you for telling about Phantom.js, this was exactly what I was looking for when I came across this question
    – xorinzor
    Dec 2 '15 at 23:48