handleLocationOf(pageObject, browser);
return result;
}
private void handleLocationOf(Class<?> pageObjectClass, WebDriver browser) {
Location location = pageObjectClass.getAnnotation(Location.class);
if (location == null) {
throw new IllegalArgumentException(String.format("The page object '%s' that you are navigating to "
+ "using either Graphene.goTo(<page_object>) or @InitialPage is not annotated with @Location",
pageObjectClass.getSimpleName()));
}
if (location.scheme() == null) {
throw new IllegalArgumentException("Scheme for provided @Location can not be a null object.");
}
Class<?> schemeClass = null;
String defaultSchemeString = configuration.get().getScheme();
try {
if (defaultSchemeString != null) {
schemeClass = SecurityActions.newInstance(defaultSchemeString);
}
} catch (IllegalArgumentException ex) {
}
if (schemeClass == null) {
schemeClass = location.scheme();
}
injector.get().inject(locationStore.get());
LocationDecider decider = resolveDecider(serviceLoader.get().all(LocationDecider.class), schemeClass);
if (decider == null) {
throw new UnsupportedOperationException(String.format("There is not any registered location decider "
+ "which can decide '%s' scheme.", location.scheme().toString()));
}
browser.get(decider.decide(location.value()));
}