Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use Selenium Server to do some web testing.... if you're not familiar with Selenium, the way it works is that my web app (in this case, a PHP script) uses Selenium's excellent API, which in turn calls on Firefox to actually interact with web pages. Then Selenium picks up the results from Firefox and returns them back to my app. Everything I have just described is working 100% perfectly on my dev sever (my desktop Mac).

Now that I know that all the right pieces are in place and my code actually works, I need to pick it all up and have it run on my live server, which is a Linux-based VPS running CentOS. I've been able to install firefox and I have the Selenium server working great, but firefox won't run because it says "Error: no display specified." (Which makes sense, since it's just a server sitting on a rack someplace.) How can I get firefox to run without a display, so Selenium will be able to interact with it? (Or-- more directly-- how do people run Selenium on a linux server when there is no display?)

FWIW I see firefox has this command line option:

X11 options
  --display=DISPLAY  X display to use

Unfortunately I don't know anything about X11 or displays under CentOS so I don't know what to specify on the command line, or if this would help.

share|improve this question

closed as too localized by John Gardeniers, mdpc, Lucas Kauffman, Khaled, Dave M Feb 1 '13 at 13:16

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

I find it very strange that a question that has been starred 13 times is closed as "too localized". – harshath.jr Jan 20 at 2:18
up vote 12 down vote accepted

Use Xvfb. It gives you an X server that doesn't require connection to a physical display.

(So, on CentOS, you'd do something like "yum install xorg-x11-server-Xvfb".)

You can then start it up on display ":1" with the command "/path/on/which/installed/Xvfb :1 -screen 0 1024x768x24 &". This will create a screen with resolution 1027x768 and depth 24. Use of "&" will make the command execute in the background.

Before launching Firefox, you need to make the display accessible, which is done using the Export command - ie. "export DISPLAY=:1", pointing to whatever host is appropriate.

share|improve this answer
Wow! Thanks! That works-- though I'm getting TONS of weird error messages from the display. I'll post a new question about those. Bottom line, despite the messages, it's working and returning the data I need. Thank you so much, this is just the help I needed. – Eric Feb 26 '12 at 8:34
By the way-- how can I "shut down" the Xvfb display when I'm done with everything? – Eric Feb 26 '12 at 8:35
You should be able to just kill the process. If you want to get more sophisticated, you can look into setting up start/stop scripts (if the package doesn't already provide it; it might: look in /etc/init.d for any xvfb script). – cjc Feb 26 '12 at 11:23
Got it, thanks. I've posted a follow-up question regarding the info/error messages I'm seeing, in case you are looking for more reputation points :-)… – Eric Feb 26 '12 at 19:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.