HTTPContext context = ModulesApi.findHTTPContext(configuration, protocolMetaData, method);
return context.getServlets().get(0).getBaseURI();
}
public void login(@Observes EventContext<Before> event) throws Exception {
Before before = event.getEvent();
UserIsLoggedIn userIsLoggedIn = null;
if (before.getTestMethod().isAnnotationPresent(UserIsLoggedIn.class)) {
userIsLoggedIn = before.getTestMethod().getAnnotation(UserIsLoggedIn.class);
} else if (before.getTestClass().isAnnotationPresent(UserIsLoggedIn.class)) {
userIsLoggedIn = before.getTestClass().getAnnotation(UserIsLoggedIn.class);
}
if (userIsLoggedIn != null) {
final URI baseUri = getBaseURI(before.getTestMethod());
final WebDriver driver = createWebDriver();
try {
driver.manage().deleteAllCookies();
driver.navigate().to(baseUri + USER_LOGIN_SERVLET_PATH + "?location=" + URLEncoder.encode(userIsLoggedIn.location(), "UTF-8"));