PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/sitebricks-acceptance-tests/src/test/java/com/google/sitebricks/acceptance/page/FormsPage.java

http://github.com/dhanji/sitebricks
Java | 54 lines | 41 code | 13 blank | 0 comment | 0 complexity | 5123c7feecd48bee9e926b322dbaa101 MD5 | raw file
 1package com.google.sitebricks.acceptance.page;
 2
 3import com.google.sitebricks.acceptance.util.AcceptanceTest;
 4import org.openqa.selenium.By;
 5import org.openqa.selenium.WebDriver;
 6import org.openqa.selenium.WebElement;
 7import org.openqa.selenium.support.PageFactory;
 8
 9import java.util.List;
10
11public class FormsPage {
12
13  private WebDriver driver;
14
15  public FormsPage(WebDriver driver) {
16    this.driver = driver;
17  }
18
19  public void enterText(String text) {
20    driver.findElement(By.name("text"))
21        .sendKeys(text);
22  }
23
24  public void send() {
25    driver.findElement(By.id("send"))
26        .submit();
27  }
28
29  public boolean hasBoundText(String someText) {
30    return driver.findElement(By.id("boundText"))
31        .getText()
32        .contains(someText);
33  }
34
35  public static FormsPage open(WebDriver driver) {
36    driver.get(AcceptanceTest.baseUrl() + "/forms");
37    return PageFactory.initElements(driver, FormsPage.class);
38  }
39
40  public void enterAutobots(String s1, String s2, String s3) {
41    final List<WebElement> autobotTextFields = driver.findElements(By.name("autobots"));
42
43    autobotTextFields.get(0).sendKeys(s1);
44    autobotTextFields.get(1).sendKeys(s2);
45    autobotTextFields.get(2).sendKeys(s3);
46  }
47
48  public boolean hasBoundAutobots(String expected) {
49    return driver.findElement(By.id("boundAutobots"))
50        .getText()
51        .contains(expected);
52
53  }
54}