Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot start browser for selenium through ssh

I am trying to setup a linux box (no display connected) to run as a selenium server. If I connect a monitor and login on the box then I can run the selenium tests no problem. If I try to run the tests via ssh then the tests fail with

Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Timed out waiting for profile to be created!
at  org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:360)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirectory(FirefoxChromeLauncher.java:114)

I think it has something to do with the display's absence / presence. Any ideas?

PS the browser is firefox 5, the OS is Ubuntu 11.04

like image 624
Dimitris Avatar asked Aug 18 '11 15:08

Dimitris


People also ask

How do I run Selenium on a remote computer?

Selenium RemoteWebDriver Installation Once the Selenium grid is installed, follow the steps below to configure the Selenium RemoteWebdriver. Open a web browser and navigate to http://localhost:4444/grid/console. The grid console page will be visible. Connect to Selenium Hub to execute test cases.

How do I start Selenium server on localhost 4444?

In your config file, set seleniumAddress to the address of the running server. This defaults to http://localhost:4444/wd/hub . To start the standalone Selenium Server from within your test script, set these options in your config file: seleniumServerJar - The location of the jar file for the standalone Selenium Server.

How can I run Selenium without opening browser?

We can perform Selenium testing without a browser. This is achieved by triggering the execution in a headless mode. The headless execution can decrease the utilization of key resources and is being adopted widely.


2 Answers

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.

like image 140
mvndaai Avatar answered Sep 27 '22 21:09

mvndaai


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
like image 35
Dimitris Avatar answered Sep 27 '22 20:09

Dimitris