OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ |
6 #define CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ | 6 #define CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/test/webdriver/commands/webdriver_command.h" | 11 #include "chrome/test/webdriver/commands/webdriver_command.h" |
12 #include "chrome/test/webdriver/web_element_id.h" | 12 #include "chrome/test/webdriver/web_element_id.h" |
13 | 13 |
| 14 namespace base { |
14 class DictionaryValue; | 15 class DictionaryValue; |
| 16 } |
15 | 17 |
16 namespace gfx { | 18 namespace gfx { |
17 class Point; | 19 class Point; |
18 } | 20 } |
19 | 21 |
20 namespace webdriver { | 22 namespace webdriver { |
21 | 23 |
22 class Error; | 24 class Error; |
23 class Response; | 25 class Response; |
24 | 26 |
25 // Handles commands that interact with a web element in the WebDriver REST | 27 // Handles commands that interact with a web element in the WebDriver REST |
26 // service. | 28 // service. |
27 class WebElementCommand : public WebDriverCommand { | 29 class WebElementCommand : public WebDriverCommand { |
28 public: | 30 public: |
29 WebElementCommand(const std::vector<std::string>& path_segments, | 31 WebElementCommand(const std::vector<std::string>& path_segments, |
30 const DictionaryValue* const parameters); | 32 const base::DictionaryValue* const parameters); |
31 virtual ~WebElementCommand(); | 33 virtual ~WebElementCommand(); |
32 | 34 |
33 virtual bool Init(Response* const response); | 35 virtual bool Init(Response* const response); |
34 | 36 |
35 protected: | 37 protected: |
36 const std::vector<std::string>& path_segments_; | 38 const std::vector<std::string>& path_segments_; |
37 WebElementId element; | 39 WebElementId element; |
38 | 40 |
39 private: | 41 private: |
40 DISALLOW_COPY_AND_ASSIGN(WebElementCommand); | 42 DISALLOW_COPY_AND_ASSIGN(WebElementCommand); |
41 }; | 43 }; |
42 | 44 |
43 // Retrieves element attributes. | 45 // Retrieves element attributes. |
44 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/attribute/:name | 46 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/attribute/:name |
45 class ElementAttributeCommand : public WebElementCommand { | 47 class ElementAttributeCommand : public WebElementCommand { |
46 public: | 48 public: |
47 ElementAttributeCommand(const std::vector<std::string>& path_segments, | 49 ElementAttributeCommand(const std::vector<std::string>& path_segments, |
48 DictionaryValue* parameters); | 50 base::DictionaryValue* parameters); |
49 virtual ~ElementAttributeCommand(); | 51 virtual ~ElementAttributeCommand(); |
50 | 52 |
51 virtual bool DoesGet(); | 53 virtual bool DoesGet(); |
52 virtual void ExecuteGet(Response* const response); | 54 virtual void ExecuteGet(Response* const response); |
53 | 55 |
54 private: | 56 private: |
55 DISALLOW_COPY_AND_ASSIGN(ElementAttributeCommand); | 57 DISALLOW_COPY_AND_ASSIGN(ElementAttributeCommand); |
56 }; | 58 }; |
57 | 59 |
58 // Clears test input elements. | 60 // Clears test input elements. |
59 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/clear | 61 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/clear |
60 class ElementClearCommand : public WebElementCommand { | 62 class ElementClearCommand : public WebElementCommand { |
61 public: | 63 public: |
62 ElementClearCommand(const std::vector<std::string>& path_segments, | 64 ElementClearCommand(const std::vector<std::string>& path_segments, |
63 DictionaryValue* parameters); | 65 base::DictionaryValue* parameters); |
64 virtual ~ElementClearCommand(); | 66 virtual ~ElementClearCommand(); |
65 | 67 |
66 virtual bool DoesPost(); | 68 virtual bool DoesPost(); |
67 virtual void ExecutePost(Response* const response); | 69 virtual void ExecutePost(Response* const response); |
68 | 70 |
69 private: | 71 private: |
70 DISALLOW_COPY_AND_ASSIGN(ElementClearCommand); | 72 DISALLOW_COPY_AND_ASSIGN(ElementClearCommand); |
71 }; | 73 }; |
72 | 74 |
73 // Retrieves element style properties. | 75 // Retrieves element style properties. |
74 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/css/:propertyName | 76 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/css/:propertyName |
75 class ElementCssCommand : public WebElementCommand { | 77 class ElementCssCommand : public WebElementCommand { |
76 public: | 78 public: |
77 ElementCssCommand(const std::vector<std::string>& path_segments, | 79 ElementCssCommand(const std::vector<std::string>& path_segments, |
78 DictionaryValue* parameters); | 80 base::DictionaryValue* parameters); |
79 virtual ~ElementCssCommand(); | 81 virtual ~ElementCssCommand(); |
80 | 82 |
81 virtual bool DoesGet(); | 83 virtual bool DoesGet(); |
82 virtual void ExecuteGet(Response* const response); | 84 virtual void ExecuteGet(Response* const response); |
83 | 85 |
84 private: | 86 private: |
85 DISALLOW_COPY_AND_ASSIGN(ElementCssCommand); | 87 DISALLOW_COPY_AND_ASSIGN(ElementCssCommand); |
86 }; | 88 }; |
87 | 89 |
88 // Queries whether an element is currently displayed ot the user. | 90 // Queries whether an element is currently displayed ot the user. |
89 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/displayed | 91 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/displayed |
90 class ElementDisplayedCommand : public WebElementCommand { | 92 class ElementDisplayedCommand : public WebElementCommand { |
91 public: | 93 public: |
92 ElementDisplayedCommand(const std::vector<std::string>& path_segments, | 94 ElementDisplayedCommand(const std::vector<std::string>& path_segments, |
93 DictionaryValue* parameters); | 95 base::DictionaryValue* parameters); |
94 virtual ~ElementDisplayedCommand(); | 96 virtual ~ElementDisplayedCommand(); |
95 | 97 |
96 virtual bool DoesGet(); | 98 virtual bool DoesGet(); |
97 virtual void ExecuteGet(Response* const response); | 99 virtual void ExecuteGet(Response* const response); |
98 | 100 |
99 private: | 101 private: |
100 DISALLOW_COPY_AND_ASSIGN(ElementDisplayedCommand); | 102 DISALLOW_COPY_AND_ASSIGN(ElementDisplayedCommand); |
101 }; | 103 }; |
102 | 104 |
103 // Queries whether an element is currently enabled. | 105 // Queries whether an element is currently enabled. |
104 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/enabled | 106 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/enabled |
105 class ElementEnabledCommand : public WebElementCommand { | 107 class ElementEnabledCommand : public WebElementCommand { |
106 public: | 108 public: |
107 ElementEnabledCommand(const std::vector<std::string>& path_segments, | 109 ElementEnabledCommand(const std::vector<std::string>& path_segments, |
108 DictionaryValue* parameters); | 110 base::DictionaryValue* parameters); |
109 virtual ~ElementEnabledCommand(); | 111 virtual ~ElementEnabledCommand(); |
110 | 112 |
111 virtual bool DoesGet(); | 113 virtual bool DoesGet(); |
112 virtual void ExecuteGet(Response* const response); | 114 virtual void ExecuteGet(Response* const response); |
113 | 115 |
114 private: | 116 private: |
115 DISALLOW_COPY_AND_ASSIGN(ElementEnabledCommand); | 117 DISALLOW_COPY_AND_ASSIGN(ElementEnabledCommand); |
116 }; | 118 }; |
117 | 119 |
118 // Queries whether two elements are equal. | 120 // Queries whether two elements are equal. |
119 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/equals/:other | 121 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/equals/:other |
120 class ElementEqualsCommand : public WebElementCommand { | 122 class ElementEqualsCommand : public WebElementCommand { |
121 public: | 123 public: |
122 ElementEqualsCommand(const std::vector<std::string>& path_segments, | 124 ElementEqualsCommand(const std::vector<std::string>& path_segments, |
123 DictionaryValue* parameters); | 125 base::DictionaryValue* parameters); |
124 virtual ~ElementEqualsCommand(); | 126 virtual ~ElementEqualsCommand(); |
125 | 127 |
126 virtual bool DoesGet(); | 128 virtual bool DoesGet(); |
127 virtual void ExecuteGet(Response* const response); | 129 virtual void ExecuteGet(Response* const response); |
128 | 130 |
129 private: | 131 private: |
130 DISALLOW_COPY_AND_ASSIGN(ElementEqualsCommand); | 132 DISALLOW_COPY_AND_ASSIGN(ElementEqualsCommand); |
131 }; | 133 }; |
132 | 134 |
133 // Retrieves the element's location on the page. | 135 // Retrieves the element's location on the page. |
134 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/location | 136 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/location |
135 class ElementLocationCommand : public WebElementCommand { | 137 class ElementLocationCommand : public WebElementCommand { |
136 public: | 138 public: |
137 ElementLocationCommand(const std::vector<std::string>& path_segments, | 139 ElementLocationCommand(const std::vector<std::string>& path_segments, |
138 DictionaryValue* parameters); | 140 base::DictionaryValue* parameters); |
139 virtual ~ElementLocationCommand(); | 141 virtual ~ElementLocationCommand(); |
140 | 142 |
141 virtual bool DoesGet(); | 143 virtual bool DoesGet(); |
142 virtual void ExecuteGet(Response* const response); | 144 virtual void ExecuteGet(Response* const response); |
143 | 145 |
144 private: | 146 private: |
145 DISALLOW_COPY_AND_ASSIGN(ElementLocationCommand); | 147 DISALLOW_COPY_AND_ASSIGN(ElementLocationCommand); |
146 }; | 148 }; |
147 | 149 |
148 // Retrieves the element's location on the page after ensuring it is visible in | 150 // Retrieves the element's location on the page after ensuring it is visible in |
149 // the current viewport. | 151 // the current viewport. |
150 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/location_in_view | 152 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/location_in_view |
151 class ElementLocationInViewCommand : public WebElementCommand { | 153 class ElementLocationInViewCommand : public WebElementCommand { |
152 public: | 154 public: |
153 ElementLocationInViewCommand(const std::vector<std::string>& path_segments, | 155 ElementLocationInViewCommand(const std::vector<std::string>& path_segments, |
154 DictionaryValue* parameters); | 156 base::DictionaryValue* parameters); |
155 virtual ~ElementLocationInViewCommand(); | 157 virtual ~ElementLocationInViewCommand(); |
156 | 158 |
157 virtual bool DoesGet(); | 159 virtual bool DoesGet(); |
158 virtual void ExecuteGet(Response* const response); | 160 virtual void ExecuteGet(Response* const response); |
159 | 161 |
160 private: | 162 private: |
161 DISALLOW_COPY_AND_ASSIGN(ElementLocationInViewCommand); | 163 DISALLOW_COPY_AND_ASSIGN(ElementLocationInViewCommand); |
162 }; | 164 }; |
163 | 165 |
164 // Queries for an element's tag name. | 166 // Queries for an element's tag name. |
165 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/name | 167 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/name |
166 class ElementNameCommand : public WebElementCommand { | 168 class ElementNameCommand : public WebElementCommand { |
167 public: | 169 public: |
168 ElementNameCommand(const std::vector<std::string>& path_segments, | 170 ElementNameCommand(const std::vector<std::string>& path_segments, |
169 DictionaryValue* parameters); | 171 base::DictionaryValue* parameters); |
170 virtual ~ElementNameCommand(); | 172 virtual ~ElementNameCommand(); |
171 | 173 |
172 virtual bool DoesGet(); | 174 virtual bool DoesGet(); |
173 virtual void ExecuteGet(Response* const response); | 175 virtual void ExecuteGet(Response* const response); |
174 | 176 |
175 private: | 177 private: |
176 DISALLOW_COPY_AND_ASSIGN(ElementNameCommand); | 178 DISALLOW_COPY_AND_ASSIGN(ElementNameCommand); |
177 }; | 179 }; |
178 | 180 |
179 // Handles selecting elements and querying whether they are currently selected. | 181 // Handles selecting elements and querying whether they are currently selected. |
180 // Queries whether an element is currently enabled. | 182 // Queries whether an element is currently enabled. |
181 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/selected | 183 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/selected |
182 class ElementSelectedCommand : public WebElementCommand { | 184 class ElementSelectedCommand : public WebElementCommand { |
183 public: | 185 public: |
184 ElementSelectedCommand(const std::vector<std::string>& path_segments, | 186 ElementSelectedCommand(const std::vector<std::string>& path_segments, |
185 DictionaryValue* parameters); | 187 base::DictionaryValue* parameters); |
186 virtual ~ElementSelectedCommand(); | 188 virtual ~ElementSelectedCommand(); |
187 | 189 |
188 virtual bool DoesGet(); | 190 virtual bool DoesGet(); |
189 virtual bool DoesPost(); | 191 virtual bool DoesPost(); |
190 virtual void ExecuteGet(Response* const response); | 192 virtual void ExecuteGet(Response* const response); |
191 virtual void ExecutePost(Response* const response); | 193 virtual void ExecutePost(Response* const response); |
192 | 194 |
193 private: | 195 private: |
194 DISALLOW_COPY_AND_ASSIGN(ElementSelectedCommand); | 196 DISALLOW_COPY_AND_ASSIGN(ElementSelectedCommand); |
195 }; | 197 }; |
196 | 198 |
197 // Queries for an element's size. | 199 // Queries for an element's size. |
198 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/size | 200 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/size |
199 class ElementSizeCommand : public WebElementCommand { | 201 class ElementSizeCommand : public WebElementCommand { |
200 public: | 202 public: |
201 ElementSizeCommand(const std::vector<std::string>& path_segments, | 203 ElementSizeCommand(const std::vector<std::string>& path_segments, |
202 DictionaryValue* parameters); | 204 base::DictionaryValue* parameters); |
203 virtual ~ElementSizeCommand(); | 205 virtual ~ElementSizeCommand(); |
204 | 206 |
205 virtual bool DoesGet(); | 207 virtual bool DoesGet(); |
206 virtual void ExecuteGet(Response* const response); | 208 virtual void ExecuteGet(Response* const response); |
207 | 209 |
208 private: | 210 private: |
209 DISALLOW_COPY_AND_ASSIGN(ElementSizeCommand); | 211 DISALLOW_COPY_AND_ASSIGN(ElementSizeCommand); |
210 }; | 212 }; |
211 | 213 |
212 // Submit's the form containing the target element. | 214 // Submit's the form containing the target element. |
213 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/submit | 215 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/submit |
214 class ElementSubmitCommand : public WebElementCommand { | 216 class ElementSubmitCommand : public WebElementCommand { |
215 public: | 217 public: |
216 ElementSubmitCommand(const std::vector<std::string>& path_segments, | 218 ElementSubmitCommand(const std::vector<std::string>& path_segments, |
217 DictionaryValue* parameters); | 219 base::DictionaryValue* parameters); |
218 virtual ~ElementSubmitCommand(); | 220 virtual ~ElementSubmitCommand(); |
219 | 221 |
220 virtual bool DoesPost(); | 222 virtual bool DoesPost(); |
221 virtual void ExecutePost(Response* const response); | 223 virtual void ExecutePost(Response* const response); |
222 | 224 |
223 private: | 225 private: |
224 DISALLOW_COPY_AND_ASSIGN(ElementSubmitCommand); | 226 DISALLOW_COPY_AND_ASSIGN(ElementSubmitCommand); |
225 }; | 227 }; |
226 | 228 |
227 // Toggle's whether an element is selected. | 229 // Toggle's whether an element is selected. |
228 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/toggle | 230 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/toggle |
229 class ElementToggleCommand : public WebElementCommand { | 231 class ElementToggleCommand : public WebElementCommand { |
230 public: | 232 public: |
231 ElementToggleCommand(const std::vector<std::string>& path_segments, | 233 ElementToggleCommand(const std::vector<std::string>& path_segments, |
232 DictionaryValue* parameters); | 234 base::DictionaryValue* parameters); |
233 virtual ~ElementToggleCommand(); | 235 virtual ~ElementToggleCommand(); |
234 | 236 |
235 virtual bool DoesPost(); | 237 virtual bool DoesPost(); |
236 virtual void ExecutePost(Response* const response); | 238 virtual void ExecutePost(Response* const response); |
237 | 239 |
238 private: | 240 private: |
239 DISALLOW_COPY_AND_ASSIGN(ElementToggleCommand); | 241 DISALLOW_COPY_AND_ASSIGN(ElementToggleCommand); |
240 }; | 242 }; |
241 | 243 |
242 // Sends keys to the specified web element. Also gets the value property of an | 244 // Sends keys to the specified web element. Also gets the value property of an |
243 // element. | 245 // element. |
244 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/value | 246 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/value |
245 class ElementValueCommand : public WebElementCommand { | 247 class ElementValueCommand : public WebElementCommand { |
246 public: | 248 public: |
247 ElementValueCommand(const std::vector<std::string>& path_segments, | 249 ElementValueCommand(const std::vector<std::string>& path_segments, |
248 DictionaryValue* parameters); | 250 base::DictionaryValue* parameters); |
249 virtual ~ElementValueCommand(); | 251 virtual ~ElementValueCommand(); |
250 | 252 |
251 virtual bool DoesGet(); | 253 virtual bool DoesGet(); |
252 virtual bool DoesPost(); | 254 virtual bool DoesPost(); |
253 virtual void ExecuteGet(Response* const response); | 255 virtual void ExecuteGet(Response* const response); |
254 virtual void ExecutePost(Response* const response); | 256 virtual void ExecutePost(Response* const response); |
255 | 257 |
256 private: | 258 private: |
257 // Returns whether the element has a given attribute pair. | 259 // Returns whether the element has a given attribute pair. |
258 Error* HasAttributeWithLowerCaseValueASCII(const std::string& key, | 260 Error* HasAttributeWithLowerCaseValueASCII(const std::string& key, |
259 const std::string& value, | 261 const std::string& value, |
260 bool* result) const; | 262 bool* result) const; |
261 Error* DragAndDropFilePaths() const; | 263 Error* DragAndDropFilePaths() const; |
262 Error* SendKeys() const; | 264 Error* SendKeys() const; |
263 | 265 |
264 DISALLOW_COPY_AND_ASSIGN(ElementValueCommand); | 266 DISALLOW_COPY_AND_ASSIGN(ElementValueCommand); |
265 }; | 267 }; |
266 | 268 |
267 // Gets the visible text of the specified web element. | 269 // Gets the visible text of the specified web element. |
268 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/text | 270 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/text |
269 class ElementTextCommand : public WebElementCommand { | 271 class ElementTextCommand : public WebElementCommand { |
270 public: | 272 public: |
271 ElementTextCommand(const std::vector<std::string>& path_segments, | 273 ElementTextCommand(const std::vector<std::string>& path_segments, |
272 DictionaryValue* parameters); | 274 base::DictionaryValue* parameters); |
273 virtual ~ElementTextCommand(); | 275 virtual ~ElementTextCommand(); |
274 | 276 |
275 virtual bool DoesGet(); | 277 virtual bool DoesGet(); |
276 virtual void ExecuteGet(Response* const response); | 278 virtual void ExecuteGet(Response* const response); |
277 | 279 |
278 private: | 280 private: |
279 DISALLOW_COPY_AND_ASSIGN(ElementTextCommand); | 281 DISALLOW_COPY_AND_ASSIGN(ElementTextCommand); |
280 }; | 282 }; |
281 | 283 |
282 } // namespace webdriver | 284 } // namespace webdriver |
283 | 285 |
284 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ | 286 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ |
OLD | NEW |