public class WebDriver2
{
public enum ENV
{
QA, STAGE,
PROD, DEV
}
public static class Environment
{
ENV env;
public Environment(ENV env)
{
this.env = env;
}
public void chooseEnvironment()
{
File file = new File("H:\\InternStuff\\Selenium\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath() );
WebDriver driver = new InternetExplorerDriver();
switch(env)
{
case QA:
driver.get("http://****/qa_was8.html");
break;
case STAGE:
driver.get("http://***/stage.html");
break;
case PROD:
driver.get("http://****/prod.html");
break;
case DEV:
driver.get("http://***/index.html");
break;
default:
String[] links;
links = new String[4];
links[0]= "http://****/qa_was8.html";
links[1]= "http://***/stage.html";
links[2]="http://****/prod.html";
links[3]="http://****/index.html";
for(int i = 0; i<links.length;i++)
{
driver.get(links[i]);
}
}
}
}
public enum App
{
ACCOUNTINVENTORY , AUDITACTIONITEMS
}
public static class Application{
App app;
public Application(App app)
{
this.app = app;
}
public void chooseApp()
{
File file = new File("H:\\InternStuff\\Selenium\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath() );
WebDriver driver = new InternetExplorerDriver();
switch(app)
{
case ACCOUNTINVENTORY:
driver.get("http://***/qa_was8.html");
driver.findElement(By.linkText("Account Inventory")).click();
driver.findElement(By.name("j_username")).sendKeys("****");
driver.findElement(By.name("j_password")).sendKeys("***");
driver.findElement(By.cssSelector("input[type='submit']")).click();
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
driver.findElement(By.className("inputText")).sendKeys("smith");
driver.findElement(By.className("commandExButton")).click();
break;
case AUDITACTIONITEMS:
driver.get("http://***/qa_was8.html");
driver.findElement(By.linkText("AuditAction Items")).click();
driver.findElement(By.name("j_username")).sendKeys("***");
driver.findElement(By.name("j_password")).sendKeys("***");
driver.findElement(By.cssSelector("input[type='submit']")).click();
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
driver.findElement(By.className("commandExButton")).click();
default:
System.out.println("Enter app name");
}
}
}
public static void main(String[] args)
{
}
}
I am working in eclipse and I am making a selenium webdriver and I need to be able to use a command line parameter where I give it an application name and an environment name (both are enums) and it run the test. I know I need to put something in the eclipse argument box Run | Run Configurations | Arguments but I am not sure what. Any help would be appreciated.