Selenium server not starting for custom firefox profile

9ikhan picture 9ikhan · Mar 30, 2011 · Viewed 13.5k times · Source

I'm trying to start the selenium server by passing custom firefox profile to the DefaultSelenium constructor. It opens the browser with specified URL.

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*custom \"C:/Program Files/Mozilla Firefox/firefox.exe\"",ReadConFile.readcoFile("serverName"));
    selenium.start();

the log is

16:39:19.246 INFO - Allocated session 4eb63d37a4ba4d2fb4e351f8f59e3ea6 for https://<myURL>, launching...

then it stays like that and server doesn't start.

however, this works fine if I don't use custom profile.

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*chrome",ReadConFile.readcoFile("serverName"));
selenium.start();

I need the launch custom profile as I've saved some site certificates necessary for https. Also, I'm executing this from eclipse.

I think my server isn't configured to launch custom profile. Please help me with this.

Answer

NathanChristie picture NathanChristie · Jun 9, 2011

The start command is not really starting your selenium server per se, it's connecting your selenium object to an already running server with the browser of your choice.

To actually start the selenium [Jetty Web] server that sends / receives commands to your application under test via your specified browser, use a batch file and the switch rs79 is referring to. The contents of your batch file should include his line:

java -jar selenium-server-standalone-2.0a5.jar -firefoxProfileTemplate C:\custom-firefox-profile

Now you have a true selenium server running on your dev machine (localhost) with the default "4444" port. This will specify that any Firefox browser testing will use this profile.

Now your DefaultSelenium constructor, assignment, and other calls can look like this:

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*firefox","http://www.server.com");
selenium.start()
selenium.open("myApp/")

Firefox will start using the custom profile specified in the batch file that starts the Selenium server, with your desired base URL, and then navigate into your desired application [URL]. If you are beginning your test from "http://www.server.com/" and not "http://www.server.com/myApp", you can omit the last open line.