//判断用什么浏览器打开
public class JavaBeanAutomation {
static {
System.setProperty(ReadProperties.BROWSER_DRIVEN,ReadProperties.BROWSER_URL);
//BROWSER_DRIVEN和BROWSER_URL是重配置文件中读取获取
}
private WebDriver webDriver;
public WebDriver getWebDriver() {
if (webDriver == null){
if (ReadProperties.BROWSER_DRIVEN.equals("webdriver.chrome.driver")){
webDriver=new ChromeDriver();
Log4j_Bean.getLogger().info("谷歌浏览器获取成功");
return webDriver;
}if (ReadProperties.BROWSER_DRIVEN.equals("webdriver.firefox.marionette")){
webDriver=new FirefoxDriver();
Log4j_Bean.getLogger().info("火狐浏览器获取成功");
return webDriver;
}if(ReadProperties.BROWSER_DRIVEN.equals("webdriver.ie.driver")){
webDriver=new InternetExplorerDriver();
Log4j_Bean.getLogger().info("IE浏览器获取成功");
return webDriver;
}else {
Log4j_Bean.getLogger().info("浏览器获取失败");
}
}
return webDriver;
}
}