You could pass the URL of the application under test to your test framework as a parameter, or store it in a properties file. I do this to switch between test environments.
Below is a simple example of reading from a properties file:
protected void startSession() {
Selenium selenium = new DefaultSelenium("localhost", 4444, "*firefox",
applicationProperties.getProperty("application.url"));
}
And an example of using a parameter (I use TestNG for this):
Add parameters in the TestNG suite XML file:
<parameter name="appURL" value="http://www.example.com/" />
Use the parameter when you create a Selenium instance:
@BeforeMethod(alwaysRun = true)
@Parameters({"appURL"})
protected void startSession(String appURL) {
Selenium selenium = new DefaultSelenium("localhost", 4444, "*firefox", appURL);
}