BrowserCapabilitiesRegistry registry = registryInstance.get();
// first, try to create a BrowserCapabilities object based on Field/Parameter type of @Drone annotated field
BrowserCapabilities browser = registry.getEntryFor(getDriverReadableName());
WebDriverConfiguration configuration = new WebDriverConfiguration(browser).configure(descriptor, qualifier);
// then, check if legacy implementationClass was set in the configuration and try to update accordingly
if (browser == null && Validate.nonEmpty(configuration.getImplementationClass())) {
browser = registry.getEntryByImplementationClassName(configuration.getImplementationClass());
if (browser == null) {
log.log(Level.FINE, "Available implementationClasses are {0}", getAvailableImplementationClasses());
throw new IllegalStateException(
MessageFormat
.format("Unable to initialize WebDriver instance. Please specify a browser property instead of implementationClass {1}. Available options are: {0}",
getAvailableBrowserCapabilities(), configuration.getImplementationClass()));
}
configuration.setBrowserInternal(browser);
log.log(Level.WARNING,
"Please use \"browser\" to specify browser type instead of implementationClass. Available options are: {0}",
getAvailableBrowserCapabilities());
}
// otherwise, we hit a webdriver configuration and we want to use browser capabilities
if (browser == null && Validate.nonEmpty(configuration.getBrowser())) {
browser = registry.getEntryFor(configuration.getBrowser());
if (browser == null) {
throw new IllegalStateException(
MessageFormat
.format("Unable to initialize WebDriver instance. Please specify a valid browser instead of {1}. Available options are: {0}",
getAvailableBrowserCapabilities(), configuration.getBrowser()));
}
configuration.setBrowserInternal(browser);
}
// if it is still null, go with defaults
if (browser == null) {
browser = registry.getEntryFor(WebDriverConfiguration.DEFAULT_BROWSER_CAPABILITIES);
log.log(Level.INFO, "Property \"browser\" was not specified, using default value of {0}",
WebDriverConfiguration.DEFAULT_BROWSER_CAPABILITIES);
configuration.setBrowserInternal(browser);
}
return configuration;
}