Pauli Price
Pauli Price

Reputation: 4237

xvfb on a machine with a display, can an application run 'in the background?'

I'm setting up to cron a web scraping job, using xvfb, firefox, and watir on my Mac OS X.

In testing the script so far, firefox pops up visibly on the local desktop, the watir script executes, and then firefox exits (I quit firefox in my script).

I'd like to set the xvfb DISPLAY such that firefox will run, but won't be seen on the local desktop, running 'in the background' so to speak.

Nothing I've been able to find online discusses such a possibility - nor explains that it's not possible.

Is it possible? If so, what do I need to do to make it work?

Upvotes: 3

Views: 3854

Answers (2)

MegaTux
MegaTux

Reputation: 1651

there's a gem called Headless for this kind of stuff. I've tried it with Selenium in my Ubuntu and works fine.

Upvotes: 1

duncan
duncan

Reputation: 6283

This is what we use to build packages whose testsuite require running Xserver in Linux:

#############################################
### Launch a virtual framebuffer X server ###
#############################################
export DISPLAY=":98"
Xvfb $DISPLAY >& Xvfb.log &
trap "kill $! || true" EXIT
sleep 10
...
# start your application/testsuite here

I tried it with firefox in a script. And does what you need (if your firefox in OSX also uses X11 of course).

Upvotes: 4

Related Questions