Polish hazelcast-spring

This commit is contained in:
Rob Winch
2017-01-09 09:36:35 -06:00
committed by John Blum
parent efeed5e2cf
commit 41e3f91b75
3 changed files with 32 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ import sample.pages.LoginPage;
/**
* @author Eddú Meléndez
* @author Rob Winch
*/
public class HazelcastSpringTests {
@@ -51,7 +52,7 @@ public class HazelcastSpringTests {
public void login() {
LoginPage login = HomePage.go(this.driver);
login.assertAt();
HomePage home = login.login();
HomePage home = login.form().login(HomePage.class);
home.containCookie("SESSION");
home.doesNotContainCookie("JSESSIONID");
}

View File

@@ -20,6 +20,7 @@ import org.openqa.selenium.WebDriver;
/**
* @author Eddú Meléndez
* @author Rob Winch
*/
public class BasePage {
@@ -34,7 +35,7 @@ public class BasePage {
}
public static void get(WebDriver driver, String get) {
String baseUrl = "http://localhost:" + System.getProperty("tomcat.port");
String baseUrl = "http://localhost:" + System.getProperty("tomcat.port", "8080");
driver.get(baseUrl + get);
}

View File

@@ -16,27 +16,21 @@
package sample.pages;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.DefaultElementLocatorFactory;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Eddú Meléndez
* @author Rob Winch
*/
public class LoginPage extends BasePage {
@FindBy(name = "username")
private WebElement username;
@FindBy(name = "password")
private WebElement password;
@FindBy(name = "submit")
private WebElement button;
public LoginPage(WebDriver driver) {
super(driver);
}
@@ -45,11 +39,31 @@ public class LoginPage extends BasePage {
assertThat(getDriver().getTitle()).isEqualTo("Login Page");
}
public HomePage login() {
this.username.sendKeys("user");
this.password.sendKeys("password");
this.button.click();
return PageFactory.initElements(getDriver(), HomePage.class);
public Form form() {
return new Form(getDriver());
}
public class Form {
@FindBy(name = "username")
private WebElement username;
@FindBy(name = "password")
private WebElement password;
@FindBy(name = "submit")
private WebElement button;
public Form(SearchContext context) {
PageFactory.initElements(new DefaultElementLocatorFactory(context), this);
}
public <T> T login(Class<T> page) {
this.username.sendKeys("user");
this.password.sendKeys("password");
this.button.click();
return PageFactory.initElements(getDriver(), page);
}
}
}