I have a set of Selenium tests which run via HTTP - I'd like to run the same tests under HTTPS aswell as HTTP with as little duplication as possible. I guess other people must already be doing this? I use the Java Selenium Remote Control - but I can probably translate a method from another language.
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);
}