Polish.
This commit is contained in:
@@ -16,14 +16,16 @@
|
||||
|
||||
package sample;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||
import sample.pages.HomePage;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import sample.pages.HomePage;
|
||||
|
||||
/**
|
||||
* @author Eddú Meléndez
|
||||
@@ -51,12 +53,8 @@ public class AttributeTests {
|
||||
@Test
|
||||
public void createAttribute() {
|
||||
HomePage home = HomePage.go(this.driver, HomePage.class);
|
||||
home = home.form()
|
||||
.attributeName("a")
|
||||
.attributeValue("b")
|
||||
.submit(HomePage.class);
|
||||
home = home.form().attributeName("a").attributeValue("b").submit(HomePage.class);
|
||||
assertThat(home.attributes()).extracting("attributeName").containsOnly("a");
|
||||
assertThat(home.attributes()).extracting("attributeValue").containsOnly("b");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package sample.pages;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -29,12 +31,11 @@ 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
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class HomePage {
|
||||
|
||||
private WebDriver driver;
|
||||
@@ -49,7 +50,7 @@ public class HomePage {
|
||||
|
||||
public HomePage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
this.attributes = new ArrayList<Attribute>();
|
||||
this.attributes = new ArrayList<>();
|
||||
}
|
||||
|
||||
private static void get(WebDriver driver, String get) {
|
||||
@@ -73,14 +74,13 @@ public class HomePage {
|
||||
}
|
||||
|
||||
public HomePage logout() {
|
||||
WebElement logout = this.driver
|
||||
.findElement(By.cssSelector("input[type=\"submit\"]"));
|
||||
WebElement logout = this.driver.findElement(By.cssSelector("input[type=\"submit\"]"));
|
||||
logout.click();
|
||||
return PageFactory.initElements(this.driver, HomePage.class);
|
||||
}
|
||||
|
||||
public List<Attribute> attributes() {
|
||||
List<Attribute> rows = new ArrayList<Attribute>();
|
||||
List<Attribute> rows = new ArrayList<>();
|
||||
for (WebElement tr : this.trs) {
|
||||
rows.add(new Attribute(tr));
|
||||
}
|
||||
@@ -93,6 +93,7 @@ public class HomePage {
|
||||
}
|
||||
|
||||
public class Form {
|
||||
|
||||
@FindBy(name = "attributeName")
|
||||
WebElement attributeName;
|
||||
|
||||
@@ -123,6 +124,7 @@ public class HomePage {
|
||||
}
|
||||
|
||||
public static class Attribute {
|
||||
|
||||
@FindBy(xpath = ".//td[1]")
|
||||
WebElement attributeName;
|
||||
|
||||
@@ -147,5 +149,4 @@ public class HomePage {
|
||||
return this.attributeValue.getText();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user