cannot start browser for selenium through ssh cannot start browser for selenium through ssh selenium selenium

cannot start browser for selenium through ssh


I got it to work by using xvfb. So first install xvfb:

sudo apt-get install xvfb

then run it

Xvfb :99 -ac

and then start the selenium server

DISPLAY=:99 java -jar selenium-server-standalone-2.4.0.jar


Here is my answer.

You get this error because there is no monitor to open firefox on, it is getting confused.

Install Xvfb, which pretends to be a monitor, but doesn't show up anywhere.
sudo apt-get install xvfb

If you want less errors add these fonts, but those warning aren't important.
sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

Then start it running and set your display to something the system won't use. Here is what I do, remeber the & makes the terminal run something in the background.
Xvfb :99 -ac &
export DISPLAY=:99
firefox &

Also I was having problems with a ruby on rails server disconnecting when I quit the ssh terminal. To fix that problem use Screen. Screen runs another terminal without being affected by the ssh.
sudo apt-get install screen

Then just start screen before you you do the stuff above.
screen

To get out of the current screen window just click "Ctrl + A" and to get back in type screen -r.


There is a good way to test using imagemagick screen shoot

Install mozilla firefox headless(no GUI)

yum install xorg-x11-server-Xvfb.x86_64 xfonts-base xfonts-75dpi xfonts-100dpi firefox ImageMagick.x86_64

Starts firefox on virtual gui

DISPLAY=:1 firefox http://google.com &

– test and check

Xvfb :1 -screen 1 1024x768x24 &ps -ef |grep firefox

Uses imagemagic to get a printscreen, to make sure its working.DISPLAY=:1 import -window root google.com.png

(Optional) Set proxy in firefox profile

vi /root/.mozilla/firefox/ns11i9xo.default/prefs.jsuser_pref(“network.proxy.http”, “proxyserver”);user_pref(“network.proxy.http_port”, 8080);user_pref(“network.proxy.no_proxies_on”, “localhost, 127.0.0.1, 172.17.0.0/16, 10.5.0.0/16″);

http://felipeferreira.net/?p=1220