1 package br.com.caelum.seleniumdsl;
2
3 import br.com.caelum.seleniumdsl.table.DefaultTable;
4 import br.com.caelum.seleniumdsl.table.Table;
5
6 import com.thoughtworks.selenium.Selenium;
7
8 class DefaultPage implements Page {
9
10 final Selenium selenium;
11 private final int timeout;
12
13 public DefaultPage(Selenium selenium, int timeout) {
14 this.selenium = selenium;
15 this.timeout = timeout;
16 }
17
18 public String title() {
19 return selenium.getTitle();
20 }
21
22 public Form form(String id) {
23 return new DefaultForm(selenium, timeout, id.equals("") ? "" : id + ".");
24 }
25
26 public ContentTag div(String id) {
27 return new DefaultContentTag(selenium, id);
28 }
29
30 public ContentTag span(String id) {
31 return new DefaultContentTag(selenium, id);
32 }
33
34 public Table table(String id) {
35 return new DefaultTable(selenium, id);
36 }
37
38 public Page navigate(String link) {
39 selenium.click(link);
40 selenium.waitForPageToLoad(Integer.toString(timeout));
41 return this;
42 }
43
44 public Page click(String element) {
45 selenium.click(element);
46 return this;
47 }
48
49 public boolean hasLink(String link) {
50 return selenium.isTextPresent(link);
51 }
52
53 public boolean isFilled(String textBoxId, String value) {
54 return selenium.getValue(textBoxId)
55 .equals(value);
56 }
57
58 public Page check(String checkbox) {
59 selenium.click(checkbox);
60 return this;
61 }
62
63 }