views:

695

answers:

1

Hi,

I'm running Selenium tests from within Eclipse, but I can't load a custom Firefox profile.

Most sources suggest I need to launch the Selenium Server like this:

java -jar selenium-server.jar -firefoxProfileTemplate </path/to/template/>

But when launching my test from within Eclipse it doesn't use that - the tests will run if the Selenium Server isn't running.

This thread suggests that I can set the profile in the DefaultSelenium constructor:

http://stackoverflow.com/questions/1126282/selenium-rc-disabling-browser-cookie

But the code generated for me by Selenium IDE (Firefox plugin) doesn't use that constructor:

package com.example.tests;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class Example extends SeleneseTestCase {
    public void setUp() throws Exception {
        setUp("http://www.example.com/", "*firefox");
    }
    public void testExample() throws Exception {
        selenium.open("/");
        selenium.click("//body");
    }
}

Where should I set the DefaultSelenium configuration options? Or is there some other method I can use to load my custom Firefox template?

Thanks! Stu

A: 

the version of code you have above assumes that you are running your tests against localhost on port 4444 thats why it is has 2 parameters in the setup.

To set up eclipse to run it you will need to update the run configuration. That is under

Run > Run Configurations 

Have a look for the item that has selenium in it and add the config above so that when it runs it will pick it up and run.

I personally just fire up the server when I start working by running a batch file and kill it at the end of the day.

AutomatedTester
Great - that got it working. Thanks!
stubotnik
You can also instantiate and start an instance of org.openqa.selenium.server.SeleniumServer if you want to do it all within the code. See .setFirefoxProfileTemplate().
dhackner