public static ESupportedDrivers parse(String original) { String parcingStr = original.toUpperCase().trim(); ESupportedDrivers[] values = ESupportedDrivers.values(); for (ESupportedDrivers enumElem : values) if (parcingStr.equals(enumElem.toString())) return enumElem; throw new IllegalArgumentException( "Webdriver with specified name " + original + " is not supported"); }
/** * Allows to instantiate the selected {@link WebDriver} by given parameters. These parameters * should correspond existing {@link WebDriver} constructors * * @param supporteddriver the selected {@link WebDriver} representation * @param values they are used to launch {@link WebDriver} */ public WebDriverEncapsulation(ESupportedDrivers supporteddriver, Object... values) { try { Class<? extends WebDriver> driverClass = supporteddriver.getUsingWebDriverClass(); AbstractApplicationContext context = new AnnotationConfigApplicationContext(WebDriverBeanConfiguration.class); enclosedDriver = (RemoteWebDriver) context.getBean( WebDriverBeanConfiguration.WEBDRIVER_BEAN, context, this, destroyableObjects, driverClass, values); Log.message("Getting started with " + driverClass.getSimpleName()); timeOut = getComponent(TimeOut.class); resetAccordingTo(configuration); this.instantiatedESupportedDriver = supporteddriver; } catch (Exception e) { Log.error( "Attempt to create a new web driver instance has been failed! " + e.getMessage(), e); destroy(); throw new RuntimeException(e); } }