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