【发布时间】:2014-06-28 03:24:33
【问题描述】:
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)
{
}
}
我在 eclipse 中工作,我正在制作一个 selenium webdriver,我需要能够使用命令行参数,我给它一个应用程序名称和一个环境名称(两者都是枚举)并运行测试。我知道我需要在 eclipse 参数框中放一些东西 运行 |运行配置 |争论,但我不确定是什么。任何帮助,将不胜感激。
【问题讨论】:
-
这是一个秘密论点吗? :P
标签: java selenium enums webdriver command-line-arguments