I would like to find out how to make URL’s variable in a Selenium project. I’m using Eclipse, Java, testNG.
We have live and test environments. Each has a different URL. The test automation suite has been coded for the test box.
What is the best way to change the URL to the live box, without having to manually change the whole project and then deploy?
The simplest way to do this is to use system properties.
You can name the system properties as
app.urland retrieve it in your test usingSystem.getProperty(String key, String default). Default URL could be a test environment.For production system property can be specified with the
-Dapp.url=http://productionsite.comVM option.As an alternative you can create a
environment.propertiesfile, specify app url as a property, and retrieve it in your tests. This file can be easily replaced for live environment.Another way to do this is to use dependency injection. Frameworks like Guice can be easily integrated with TestNG.