Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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());
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