1   package com.atlassian.selenium.pageobjects;
2   
3   import com.atlassian.selenium.SeleniumClient;
4   
5   public class PageElement {
6       protected final String locator;
7       protected final SeleniumClient client;
8   
9   
10      public PageElement(String locator, SeleniumClient client)
11      {
12          this.locator = locator;
13          this.client = client;
14      }
15  
16      public boolean isPresent()
17      {
18          return client.isElementPresent(locator);
19      }
20  
21      public void click()
22      {
23          client.click(locator);
24      }
25  
26      public String getLocator()
27      {
28          return locator;
29      }
30  
31      public String toString()
32      {
33          return locator;
34      }
35  
36      public String getText()
37      {
38          return client.getText(locator);
39      }
40  
41      public int getPositionTop()
42      {
43          return client.getElementPositionTop(locator).intValue();
44      }
45  
46      public int getPositionLeft()
47      {
48          return client.getElementPositionLeft(locator).intValue();
49      }
50  
51      public int getWidth()
52      {
53          return client.getElementWidth(locator).intValue();
54      }
55  
56      public int getHeight()
57      {
58          return client.getElementHeight(locator).intValue();
59      }
60  
61      public void contextMenu(PageElement element)
62      {
63          client.contextMenu(element.getLocator());
64      }
65  
66      public void doubleClick()
67      {
68          client.doubleClick(getLocator());
69      }
70  
71      public void dragAndDrop(String movementsString)
72      {
73          client.dragAndDrop(getLocator(), movementsString);
74      }
75  
76      public void dragAndDropToObject(PageElement dest)
77      {
78          client.dragAndDropToObject(getLocator(), dest.getLocator());
79      }
80  
81      public void focus()
82      {
83          client.focus(getLocator());
84      }
85  
86      public void getCursorPosition()
87      {
88          client.getCursorPosition(getLocator());
89      }
90  
91      public Number getIndex()
92      {
93          return client.getElementIndex(getLocator());
94      }
95  
96  
97      public void highlight()
98      {
99          client.highlight(getLocator());
100     }
101 
102 
103     public void mouseDown()
104     {
105         client.mouseDown(getLocator());
106     }
107 
108     public void mouseDownRight()
109     {
110         client.mouseDownRight(getLocator());
111     }
112 
113     public void mouseMove()
114     {
115         client.mouseDown(getLocator());
116     }
117 
118     public void mouseOut()
119     {
120         client.mouseOut(getLocator());
121     }
122 
123     public void mouseOver()
124     {
125         client.mouseOver(getLocator());
126     }
127 
128     public void mouseUp()
129     {
130         client.mouseUp(getLocator());
131     }
132 
133     public void mouseUpRight()
134     {
135         client.mouseUpRight(getLocator());
136     }
137 
138     public boolean isVisible()
139     {
140         return client.isElementPresent(getLocator()) && client.isVisible(getLocator());
141     }
142 
143     public boolean isEditable()
144     {
145         return client.isEditable(getLocator());
146     }
147 
148     public void keyDown(String keyCode)
149     {
150         client.keyDown(getLocator(), keyCode);
151     }
152 
153     public void keyPress(String keyCode)
154     {
155         client.keyPress(getLocator(), keyCode);
156     }
157 
158     public void keyUp(String keyCode)
159     {
160         client.keyUp(getLocator(), keyCode);
161     }
162     
163     public void type(String value)
164     {
165         client.type(getLocator(), value);
166     }
167 
168     public void typeKeys(String value)
169     {
170         client.typeKeys(getLocator(), value);
171     }
172 
173     public void typeWithFullKeyEvents(String value)
174     {
175         client.typeWithFullKeyEvents(getLocator(), value);
176     }    
177 }