Last active
January 21, 2020 17:26
-
-
Save eliasnogueira/3413c5622716e6d73a6eaf9e59f296b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocalDriverManager { | |
// to make this work just pass the browser name, that must match from the DriverManagerType class | |
public WebDriver createInstance(String browser) { | |
WebDriver driver = null; | |
try { | |
DriverManagerType driverManagerType = DriverManagerType.valueOf(browser.toUpperCase()); | |
Class<?> driverClass = Class.forName(driverManagerType.browserClass()); | |
WebDriverManager.getInstance(driverManagerType).setup(); | |
driver = (WebDriver) driverClass.newInstance(); | |
} catch (IllegalAccessException | ClassNotFoundException e) { | |
// exception or log for class not found | |
} catch (InstantiationException e) { | |
// exception of log for instantiation problem | |
} | |
return driver; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment