1
2
3
4 package org.sirius.client.web.classes;
5
6 import java.rmi.RemoteException;
7
8 import org.sirius.client.web.WebClient;
9 import org.sirius.client.web.core.Dimension;
10 import org.sirius.client.web.core.Point;
11
12
13
14
15
16 public class WebControl {
17
18
19
20
21 private WebClient client = null;
22
23
24
25 private Frame parent = null;
26
27
28
29 private String parentElement = null;
30
31
32
33 private String locator = null;
34
35
36
37
38 public final WebClient getClient() {
39 return client;
40 }
41
42
43
44
45 public final void setClient(final WebClient clientValue) {
46 this.client = clientValue;
47 }
48
49
50
51
52 public final Frame getParent() {
53 return parent;
54 }
55
56
57
58
59 public final void setParent(final Frame parentValue) {
60 this.parent = parentValue;
61 }
62
63
64
65
66 public final String getParentElement() {
67 return parentElement;
68 }
69
70
71
72
73 public final void setParentElement(final String parentElementValue) {
74 this.parentElement = parentElementValue;
75 }
76
77
78
79
80 public final String getLocator() {
81 return locator;
82 }
83
84
85
86
87 public final void setLocator(final String locatorValue) {
88 this.locator = locatorValue;
89 }
90
91
92
93
94
95
96 public WebControl(final Frame parentValue, final String locatorValue) {
97 this(parentValue, null, locatorValue);
98 }
99
100
101
102
103
104
105
106 public WebControl(final Frame parentValue, final String parentElementValue,
107 final String locatorValue) {
108 this.parent = parentValue;
109 this.parentElement = parentElementValue;
110 this.locator = locatorValue;
111 }
112
113
114
115
116
117 public final void click() throws Exception {
118 client().core().click(parentElement, locator);
119 }
120
121
122
123
124
125 protected final WebClient client() {
126 if (client == null) {
127 client = getParent().getClient();
128 }
129 return client;
130 }
131
132
133
134
135
136
137
138 public final String getAttribute(final String attribute)
139 throws RemoteException {
140 return client().core().getAttribute(
141 parentElement,
142 locator,
143 attribute);
144 }
145
146
147
148
149
150
151 public final Point getLocation() throws RemoteException {
152 return client().core().getLocation(parentElement, locator);
153 }
154
155
156
157
158
159
160 public final Dimension getSize() throws RemoteException {
161 return client().core().getSize(parentElement, locator);
162 }
163
164
165
166
167
168
169 public final String getValue() throws RemoteException {
170 return getAttribute("value");
171 }
172
173
174
175
176
177
178 public final String innerHtml() throws RemoteException {
179 return client().core()
180 .getAttribute(parentElement, locator, "innerHTML");
181 }
182
183
184
185
186
187
188 public final String innerText() throws RemoteException {
189 return client().core()
190 .getAttribute(parentElement, locator, "innerText");
191 }
192
193
194
195
196
197
198 public final boolean isFocused() throws RemoteException {
199 return false;
200 }
201 }