I actually tried that, however, got this exception when instantiating the webdriver.
java.lang.ClassCastException: org.openqa.selenium.remote.service.DriverCommandExecutor cannot be cast to org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor
String firefoxLocation = System.getenv("ProgramFiles") + "\\Mozilla Firefox_42\\firefox.exe";
String geckoLocation = "..\\framework-test\\gecko\\geckodriver_15.exe";
try
{
//Lets determine what browser we will be using, then load the appropriate driver
switch (browser.toLowerCase())
{
case "firefox" :
{
System.setProperty("webdriver.gecko.driver", geckoLocation);
System.setProperty("webdriver.firefox.bin", firefoxLocation);
System.setProperty("webdriver.reap_profile", "false");
//Set the capabilities
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", false);
dc.setCapability("acceptSslCerts", true);
dc.setCapability("acceptInsecureCerts", true);
//Set the profile
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
//Disable Firefox Auto-Updating
profile.setPreference("app.update.auto", false);
profile.setPreference("app.update.enabled", false);
dc.setCapability(FirefoxDriver.PROFILE, profile);
driver = new FirefoxDriver(dc);
Log.info("*****Opened Firefox");
break;
}
case "chrome" :
{
System.setProperty("webdriver.chrome.driver", "libs//chromedriver.exe");
driver = new ChromeDriver();
break;
}
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
catch (Exception e)
{
Log.info("Class Utils | Method OpenBrowser | Exception desc : " + e.getMessage());
Log.error("Class Utils | Method OpenBrowser | Exception desc : " + e.getMessage());
}
return driver;