diff --git a/gradle.properties b/gradle.properties index 353e0349..fb344226 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,4 +28,3 @@ spockVersion=1.0-groovy-2.4 webjarsTaglibVersion=0.3 jstlVersion=1.2.1 groovyVersion=2.4.4 -lombokVersion=1.16.8 diff --git a/samples/custom-cookie/build.gradle b/samples/custom-cookie/build.gradle index 41b0360a..2c575350 100644 --- a/samples/custom-cookie/build.gradle +++ b/samples/custom-cookie/build.gradle @@ -15,8 +15,7 @@ dependencies { providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies } diff --git a/samples/custom-cookie/src/integration-test/java/sample/pages/HomePage.java b/samples/custom-cookie/src/integration-test/java/sample/pages/HomePage.java index 00e29651..7bc855fb 100644 --- a/samples/custom-cookie/src/integration-test/java/sample/pages/HomePage.java +++ b/samples/custom-cookie/src/integration-test/java/sample/pages/HomePage.java @@ -19,14 +19,12 @@ package sample.pages; import java.util.ArrayList; import java.util.List; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Data; -import lombok.Getter; -import org.openqa.selenium.By; +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; @@ -37,6 +35,18 @@ public class HomePage { private WebDriver driver; + @FindBy(name = "attributeName") + WebElement attributeName; + + @FindBy(name = "attributeValue") + WebElement attributeValue; + + @FindBy(css = "input[type=\"submit\"]") + WebElement submit; + + @FindBy(css = "table tbody tr") + List trs; + private List rows; public HomePage(WebDriver driver) { @@ -45,7 +55,7 @@ public class HomePage { } private 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); } @@ -59,30 +69,16 @@ public class HomePage { } public void addAttribute(String name, String value) { - WebElement form = this.driver.findElement(By.tagName("form")); - WebElement attributeName = form.findElement(By.name("attributeName")); - WebElement attributeValue = form.findElement(By.name("attributeValue")); + this.attributeName.sendKeys(name); + this.attributeValue.sendKeys(value); - attributeName.sendKeys(name); - attributeValue.sendKeys(value); - - form.findElement(By.cssSelector("input[type=\"submit\"]")).click(); + this.submit.click(); } public List attributes() { - WebElement table = this.driver.findElement(By.tagName("table")); - WebElement tbody = table.findElement(By.tagName("tbody")); - List trs = tbody.findElements(By.tagName("tr")); - List rows = new ArrayList(); - for (WebElement tr : trs) { - List tds = tr.findElements(By.cssSelector("td")); - Row row = Row.builder() - .driver(this.driver) - .attributeName(tds.get(0).getText()) - .attributeValue(tds.get(1).getText()) - .build(); - rows.add(row); + for (WebElement tr : this.trs) { + rows.add(new Row(tr)); } this.rows.addAll(rows); return this.rows; @@ -92,17 +88,33 @@ public class HomePage { return this.rows.get(index); } - @Data - @Builder public static class Row { + @FindBy(xpath = "//td[1]") + WebElement attributeName; - final String attributeName; + @FindBy(xpath = "//td[2]") + WebElement attributeValue; - final String attributeValue; + public Row(SearchContext context) { + super(); + DefaultElementLocatorFactory factory = new DefaultElementLocatorFactory( + context); + PageFactory.initElements(factory, this); + } - @Getter(AccessLevel.PRIVATE) - final WebDriver driver; + /** + * @return the attributeName + */ + public String getAttributeName() { + return this.attributeName.getText(); + } + /** + * @return the attributeValue + */ + public String getAttributeValue() { + return this.attributeValue.getText(); + } } } diff --git a/samples/findbyusername/build.gradle b/samples/findbyusername/build.gradle index 80d4ad5c..ccafb4eb 100644 --- a/samples/findbyusername/build.gradle +++ b/samples/findbyusername/build.gradle @@ -30,8 +30,7 @@ dependencies { "org.apache.httpcomponents:httpclient" testCompile "org.springframework.boot:spring-boot-starter-test", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies diff --git a/samples/hazelcast/build.gradle b/samples/hazelcast/build.gradle index 3d1a8955..2e589514 100644 --- a/samples/hazelcast/build.gradle +++ b/samples/hazelcast/build.gradle @@ -12,8 +12,7 @@ dependencies { providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies } diff --git a/samples/httpsession-gemfire-boot/build.gradle b/samples/httpsession-gemfire-boot/build.gradle index 06d1ddb6..6b18008e 100644 --- a/samples/httpsession-gemfire-boot/build.gradle +++ b/samples/httpsession-gemfire-boot/build.gradle @@ -29,8 +29,7 @@ dependencies { testCompile "org.springframework.boot:spring-boot-starter-test" - integrationTestCompile seleniumDependencies, - "org.projectlombok:lombok:$lombokVersion" + integrationTestCompile seleniumDependencies integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE" } diff --git a/samples/httpsession-gemfire-clientserver-xml/build.gradle b/samples/httpsession-gemfire-clientserver-xml/build.gradle index 38b07825..23d0be94 100644 --- a/samples/httpsession-gemfire-clientserver-xml/build.gradle +++ b/samples/httpsession-gemfire-clientserver-xml/build.gradle @@ -20,8 +20,7 @@ dependencies { runtime "org.springframework.shell:spring-shell:1.0.0.RELEASE" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies diff --git a/samples/httpsession-gemfire-clientserver/build.gradle b/samples/httpsession-gemfire-clientserver/build.gradle index ed125ba3..f4b80911 100644 --- a/samples/httpsession-gemfire-clientserver/build.gradle +++ b/samples/httpsession-gemfire-clientserver/build.gradle @@ -15,8 +15,7 @@ dependencies { runtime "org.springframework.shell:spring-shell:1.0.0.RELEASE" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies diff --git a/samples/httpsession-gemfire-p2p-xml/build.gradle b/samples/httpsession-gemfire-p2p-xml/build.gradle index 3278a77e..d2443a35 100644 --- a/samples/httpsession-gemfire-p2p-xml/build.gradle +++ b/samples/httpsession-gemfire-p2p-xml/build.gradle @@ -14,8 +14,7 @@ dependencies { testCompile "junit:junit:$junitVersion" integrationTestCompile seleniumDependencies, - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE" } diff --git a/samples/httpsession-gemfire-p2p/build.gradle b/samples/httpsession-gemfire-p2p/build.gradle index 3278a77e..d2443a35 100644 --- a/samples/httpsession-gemfire-p2p/build.gradle +++ b/samples/httpsession-gemfire-p2p/build.gradle @@ -14,8 +14,7 @@ dependencies { testCompile "junit:junit:$junitVersion" integrationTestCompile seleniumDependencies, - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestRuntime "org.springframework.shell:spring-shell:1.0.0.RELEASE" } diff --git a/samples/httpsession-jdbc-boot/build.gradle b/samples/httpsession-jdbc-boot/build.gradle index f3869ceb..c621e7fc 100644 --- a/samples/httpsession-jdbc-boot/build.gradle +++ b/samples/httpsession-jdbc-boot/build.gradle @@ -29,8 +29,7 @@ dependencies { "com.h2database:h2" testCompile "org.springframework.boot:spring-boot-starter-test", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies diff --git a/samples/httpsession-jdbc-xml/build.gradle b/samples/httpsession-jdbc-xml/build.gradle index efb72306..6c418977 100644 --- a/samples/httpsession-jdbc-xml/build.gradle +++ b/samples/httpsession-jdbc-xml/build.gradle @@ -13,8 +13,7 @@ dependencies { providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies } diff --git a/samples/httpsession-jdbc/build.gradle b/samples/httpsession-jdbc/build.gradle index efb72306..6c418977 100644 --- a/samples/httpsession-jdbc/build.gradle +++ b/samples/httpsession-jdbc/build.gradle @@ -13,8 +13,7 @@ dependencies { providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies } diff --git a/samples/httpsession-redis-json/build.gradle b/samples/httpsession-redis-json/build.gradle index e1d4bda4..42559999 100644 --- a/samples/httpsession-redis-json/build.gradle +++ b/samples/httpsession-redis-json/build.gradle @@ -33,8 +33,7 @@ dependencies { "org.apache.httpcomponents:httpclient" testCompile "org.springframework.boot:spring-boot-starter-test", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" testCompile "org.skyscreamer:jsonassert:$jsonassertVersion" integrationTestCompile seleniumDependencies diff --git a/samples/httpsession-redis-json/src/integration-test/java/samples/pages/LoginPage.java b/samples/httpsession-redis-json/src/integration-test/java/samples/pages/LoginPage.java index 8a4403cb..265c6046 100644 --- a/samples/httpsession-redis-json/src/integration-test/java/samples/pages/LoginPage.java +++ b/samples/httpsession-redis-json/src/integration-test/java/samples/pages/LoginPage.java @@ -19,14 +19,13 @@ package samples.pages; import java.util.ArrayList; import java.util.List; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Data; -import lombok.Getter; import org.openqa.selenium.By; +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; @@ -71,35 +70,41 @@ public class LoginPage extends BasePage { } public List attributes() { - WebElement table = getDriver().findElement(By.tagName("table")); - List trs = table.findElements(By.tagName("tr")); + List trs = getDriver().findElements(By.cssSelector("table tbody tr")); List rows = new ArrayList(); for (WebElement tr : trs) { - List tds = tr.findElements(By.cssSelector("td")); - if (!tds.isEmpty()) { - Row row = Row.builder() - .driver(getDriver()) - .key(tds.get(0).getText()) - .value(tds.get(1).getText()) - .build(); - rows.add(row); - } + rows.add(new Row(tr)); } return rows; } - @Data - @Builder public static class Row { + @FindBy(css = "td:text") + String key; - final String key; + @FindBy(css = "td:last.text()") + String value; - final String value; + public Row(SearchContext context) { + super(); + DefaultElementLocatorFactory factory = new DefaultElementLocatorFactory(context); + PageFactory.initElements(factory, this); + } - @Getter(AccessLevel.PRIVATE) - final WebDriver driver; + /** + * @return the key + */ + public String getKey() { + return this.key; + } + /** + * @return the value + */ + public String getValue() { + return this.value; + } } } diff --git a/samples/httpsession-redis-json/src/main/resources/templates/home.html b/samples/httpsession-redis-json/src/main/resources/templates/home.html index 6c8f667a..78c74c3d 100644 --- a/samples/httpsession-redis-json/src/main/resources/templates/home.html +++ b/samples/httpsession-redis-json/src/main/resources/templates/home.html @@ -19,14 +19,18 @@
- - - - - - - - + + + + + + + + + + + +
Attribute NameAttribute Value
Attribute NameAttribute Value
diff --git a/samples/httpsession-xml/build.gradle b/samples/httpsession-xml/build.gradle index 41b0360a..2c575350 100644 --- a/samples/httpsession-xml/build.gradle +++ b/samples/httpsession-xml/build.gradle @@ -15,8 +15,7 @@ dependencies { providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies } diff --git a/samples/httpsession/build.gradle b/samples/httpsession/build.gradle index 41b0360a..2c575350 100644 --- a/samples/httpsession/build.gradle +++ b/samples/httpsession/build.gradle @@ -15,8 +15,7 @@ dependencies { providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion" testCompile "junit:junit:$junitVersion", - "org.assertj:assertj-core:$assertjVersion", - "org.projectlombok:lombok:$lombokVersion" + "org.assertj:assertj-core:$assertjVersion" integrationTestCompile seleniumDependencies }