1
我是使用硒進行自動化測試的新手。這就是爲什麼,我面臨着從用戶輸入中獲取瀏覽器和URL的問題。像,當執行我的代碼,第一個用戶輸入choosen爲您的組織和第二個是choosen爲您的網址像谷歌,Facebook等我如何選擇瀏覽器,然後從用戶選擇我的具體網址
public class Pages {
private enum Organization {
Firefox, Chrom
}
static Organization obj;
private static Pages Chrom;
private static Scanner reader;
private static Scanner reader_1;
public static void main(String[]args) throws InterruptedException {
char ch;
String org;
do
{
System.out.println("");
reader = new Scanner(System.in);
System.out.println("Please Enter The Browser Name :");
org = reader.nextLine();
obj=Organization.valueOf(org);
switch(obj)
{
case Firefox:
Pages.Firefoxdriver();
break;
case Chrom:
Pages.Chromedriver();
break;
default:
System.out.println("You Have Selected Wrong Browser ");
}
reader_1 = new Scanner(System.in);
System.out.println("Please a key followed by ENTER: \n ");
ch = reader_1.next().charAt(0);
} while (ch != 'q');
}
public static void Firefoxdriver(){
WebDriver driver = new FirefoxDriver();
driver.get("http://qa-0.ls.vu");
}
public static void Chromedriver(){
System.setProperty("webdriver.chrome.driver","E:\\workspace\\chromeDriver\\chromeDriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.get("http://qa-0.ls.vu");
}
public void IEdriver(){
File file =new File("C:/Users/mkv/workspace/ServerDrivers/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driverIE=new InternetExplorerDriver();
driverIE.navigate().to("http://www.msn.com");
}
}
你會通過 「選擇您的組織」 做 – thebadguy