OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/test/webdriver/commands/webelement_commands.h" | 5 #include "chrome/test/webdriver/commands/webelement_commands.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // We cannot verify the ID is valid until we execute the command and | 45 // We cannot verify the ID is valid until we execute the command and |
46 // inject the ID into the in-page cache. | 46 // inject the ID into the in-page cache. |
47 element = ElementId(path_segments_.at(4)); | 47 element = ElementId(path_segments_.at(4)); |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 ///////////////////// ElementAttributeCommand //////////////////// | 51 ///////////////////// ElementAttributeCommand //////////////////// |
52 | 52 |
53 ElementAttributeCommand::ElementAttributeCommand( | 53 ElementAttributeCommand::ElementAttributeCommand( |
54 const std::vector<std::string>& path_segments, | 54 const std::vector<std::string>& path_segments, |
55 DictionaryValue* parameters) | 55 const DictionaryValue* parameters) |
56 : WebElementCommand(path_segments, parameters) {} | 56 : WebElementCommand(path_segments, parameters) {} |
57 | 57 |
58 ElementAttributeCommand::~ElementAttributeCommand() {} | 58 ElementAttributeCommand::~ElementAttributeCommand() {} |
59 | 59 |
60 bool ElementAttributeCommand::DoesGet() { | 60 bool ElementAttributeCommand::DoesGet() { |
61 return true; | 61 return true; |
62 } | 62 } |
63 | 63 |
64 void ElementAttributeCommand::ExecuteGet(Response* const response) { | 64 void ElementAttributeCommand::ExecuteGet(Response* const response) { |
65 // There should be at least 7 segments to match | 65 // There should be at least 7 segments to match |
(...skipping 11 matching lines...) Expand all Loading... |
77 return; | 77 return; |
78 } | 78 } |
79 | 79 |
80 response->SetValue(value); | 80 response->SetValue(value); |
81 } | 81 } |
82 | 82 |
83 ///////////////////// ElementClearCommand //////////////////// | 83 ///////////////////// ElementClearCommand //////////////////// |
84 | 84 |
85 ElementClearCommand::ElementClearCommand( | 85 ElementClearCommand::ElementClearCommand( |
86 const std::vector<std::string>& path_segments, | 86 const std::vector<std::string>& path_segments, |
87 DictionaryValue* parameters) | 87 const DictionaryValue* parameters) |
88 : WebElementCommand(path_segments, parameters) {} | 88 : WebElementCommand(path_segments, parameters) {} |
89 | 89 |
90 ElementClearCommand::~ElementClearCommand() {} | 90 ElementClearCommand::~ElementClearCommand() {} |
91 | 91 |
92 bool ElementClearCommand::DoesPost() { | 92 bool ElementClearCommand::DoesPost() { |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 void ElementClearCommand::ExecutePost(Response* const response) { | 96 void ElementClearCommand::ExecutePost(Response* const response) { |
97 ListValue args; | 97 ListValue args; |
98 args.Append(element.ToValue()); | 98 args.Append(element.ToValue()); |
99 | 99 |
100 std::string script = base::StringPrintf( | 100 std::string script = base::StringPrintf( |
101 "(%s).apply(null, arguments);", atoms::asString(atoms::CLEAR).c_str()); | 101 "(%s).apply(null, arguments);", atoms::asString(atoms::CLEAR).c_str()); |
102 | 102 |
103 Value* result = NULL; | 103 Value* result = NULL; |
104 Error* error = session_->ExecuteScript(script, &args, &result); | 104 Error* error = session_->ExecuteScript(script, &args, &result); |
105 if (error) { | 105 if (error) { |
106 response->SetError(error); | 106 response->SetError(error); |
107 return; | 107 return; |
108 } | 108 } |
109 response->SetValue(result); | 109 response->SetValue(result); |
110 } | 110 } |
111 | 111 |
112 ///////////////////// ElementCssCommand //////////////////// | 112 ///////////////////// ElementCssCommand //////////////////// |
113 | 113 |
114 ElementCssCommand::ElementCssCommand( | 114 ElementCssCommand::ElementCssCommand( |
115 const std::vector<std::string>& path_segments, | 115 const std::vector<std::string>& path_segments, |
116 DictionaryValue* parameters) | 116 const DictionaryValue* parameters) |
117 : WebElementCommand(path_segments, parameters) {} | 117 : WebElementCommand(path_segments, parameters) {} |
118 | 118 |
119 ElementCssCommand::~ElementCssCommand() {} | 119 ElementCssCommand::~ElementCssCommand() {} |
120 | 120 |
121 bool ElementCssCommand::DoesGet() { | 121 bool ElementCssCommand::DoesGet() { |
122 return true; | 122 return true; |
123 } | 123 } |
124 | 124 |
125 void ElementCssCommand::ExecuteGet(Response* const response) { | 125 void ElementCssCommand::ExecuteGet(Response* const response) { |
126 // There should be at least 7 segments to match | 126 // There should be at least 7 segments to match |
(...skipping 17 matching lines...) Expand all Loading... |
144 response->SetError(error); | 144 response->SetError(error); |
145 return; | 145 return; |
146 } | 146 } |
147 response->SetValue(result); | 147 response->SetValue(result); |
148 } | 148 } |
149 | 149 |
150 ///////////////////// ElementDisplayedCommand //////////////////// | 150 ///////////////////// ElementDisplayedCommand //////////////////// |
151 | 151 |
152 ElementDisplayedCommand::ElementDisplayedCommand( | 152 ElementDisplayedCommand::ElementDisplayedCommand( |
153 const std::vector<std::string>& path_segments, | 153 const std::vector<std::string>& path_segments, |
154 DictionaryValue* parameters) | 154 const DictionaryValue* parameters) |
155 : WebElementCommand(path_segments, parameters) {} | 155 : WebElementCommand(path_segments, parameters) {} |
156 | 156 |
157 ElementDisplayedCommand::~ElementDisplayedCommand() {} | 157 ElementDisplayedCommand::~ElementDisplayedCommand() {} |
158 | 158 |
159 bool ElementDisplayedCommand::DoesGet() { | 159 bool ElementDisplayedCommand::DoesGet() { |
160 return true; | 160 return true; |
161 } | 161 } |
162 | 162 |
163 void ElementDisplayedCommand::ExecuteGet(Response* const response) { | 163 void ElementDisplayedCommand::ExecuteGet(Response* const response) { |
164 bool is_displayed; | 164 bool is_displayed; |
165 Error* error = session_->IsElementDisplayed( | 165 Error* error = session_->IsElementDisplayed( |
166 session_->current_target(), element, false /* ignore_opacity */, | 166 session_->current_target(), element, false /* ignore_opacity */, |
167 &is_displayed); | 167 &is_displayed); |
168 if (error) { | 168 if (error) { |
169 response->SetError(error); | 169 response->SetError(error); |
170 return; | 170 return; |
171 } | 171 } |
172 response->SetValue(Value::CreateBooleanValue(is_displayed)); | 172 response->SetValue(Value::CreateBooleanValue(is_displayed)); |
173 } | 173 } |
174 | 174 |
175 ///////////////////// ElementEnabledCommand //////////////////// | 175 ///////////////////// ElementEnabledCommand //////////////////// |
176 | 176 |
177 ElementEnabledCommand::ElementEnabledCommand( | 177 ElementEnabledCommand::ElementEnabledCommand( |
178 const std::vector<std::string>& path_segments, | 178 const std::vector<std::string>& path_segments, |
179 DictionaryValue* parameters) | 179 const DictionaryValue* parameters) |
180 : WebElementCommand(path_segments, parameters) {} | 180 : WebElementCommand(path_segments, parameters) {} |
181 | 181 |
182 ElementEnabledCommand::~ElementEnabledCommand() {} | 182 ElementEnabledCommand::~ElementEnabledCommand() {} |
183 | 183 |
184 bool ElementEnabledCommand::DoesGet() { | 184 bool ElementEnabledCommand::DoesGet() { |
185 return true; | 185 return true; |
186 } | 186 } |
187 | 187 |
188 void ElementEnabledCommand::ExecuteGet(Response* const response) { | 188 void ElementEnabledCommand::ExecuteGet(Response* const response) { |
189 ListValue args; | 189 ListValue args; |
190 args.Append(element.ToValue()); | 190 args.Append(element.ToValue()); |
191 | 191 |
192 std::string script = base::StringPrintf( | 192 std::string script = base::StringPrintf( |
193 "return (%s).apply(null, arguments);", | 193 "return (%s).apply(null, arguments);", |
194 atoms::asString(atoms::IS_ENABLED).c_str()); | 194 atoms::asString(atoms::IS_ENABLED).c_str()); |
195 | 195 |
196 Value* result = NULL; | 196 Value* result = NULL; |
197 Error* error = session_->ExecuteScript(script, &args, &result); | 197 Error* error = session_->ExecuteScript(script, &args, &result); |
198 if (error) { | 198 if (error) { |
199 response->SetError(error); | 199 response->SetError(error); |
200 return; | 200 return; |
201 } | 201 } |
202 response->SetValue(result); | 202 response->SetValue(result); |
203 } | 203 } |
204 | 204 |
205 ///////////////////// ElementEqualsCommand //////////////////// | 205 ///////////////////// ElementEqualsCommand //////////////////// |
206 | 206 |
207 ElementEqualsCommand::ElementEqualsCommand( | 207 ElementEqualsCommand::ElementEqualsCommand( |
208 const std::vector<std::string>& path_segments, | 208 const std::vector<std::string>& path_segments, |
209 DictionaryValue* parameters) | 209 const DictionaryValue* parameters) |
210 : WebElementCommand(path_segments, parameters) {} | 210 : WebElementCommand(path_segments, parameters) {} |
211 | 211 |
212 ElementEqualsCommand::~ElementEqualsCommand() {} | 212 ElementEqualsCommand::~ElementEqualsCommand() {} |
213 | 213 |
214 bool ElementEqualsCommand::DoesGet() { | 214 bool ElementEqualsCommand::DoesGet() { |
215 return true; | 215 return true; |
216 } | 216 } |
217 | 217 |
218 void ElementEqualsCommand::ExecuteGet(Response* const response) { | 218 void ElementEqualsCommand::ExecuteGet(Response* const response) { |
219 // There should be at least 7 segments to match | 219 // There should be at least 7 segments to match |
(...skipping 17 matching lines...) Expand all Loading... |
237 response->SetError(error); | 237 response->SetError(error); |
238 return; | 238 return; |
239 } | 239 } |
240 response->SetValue(result); | 240 response->SetValue(result); |
241 } | 241 } |
242 | 242 |
243 ///////////////////// ElementLocationCommand //////////////////// | 243 ///////////////////// ElementLocationCommand //////////////////// |
244 | 244 |
245 ElementLocationCommand::ElementLocationCommand( | 245 ElementLocationCommand::ElementLocationCommand( |
246 const std::vector<std::string>& path_segments, | 246 const std::vector<std::string>& path_segments, |
247 DictionaryValue* parameters) | 247 const DictionaryValue* parameters) |
248 : WebElementCommand(path_segments, parameters) {} | 248 : WebElementCommand(path_segments, parameters) {} |
249 | 249 |
250 ElementLocationCommand::~ElementLocationCommand() {} | 250 ElementLocationCommand::~ElementLocationCommand() {} |
251 | 251 |
252 bool ElementLocationCommand::DoesGet() { | 252 bool ElementLocationCommand::DoesGet() { |
253 return true; | 253 return true; |
254 } | 254 } |
255 | 255 |
256 void ElementLocationCommand::ExecuteGet(Response* const response) { | 256 void ElementLocationCommand::ExecuteGet(Response* const response) { |
257 std::string script = base::StringPrintf( | 257 std::string script = base::StringPrintf( |
258 "return (%s).apply(null, arguments);", | 258 "return (%s).apply(null, arguments);", |
259 atoms::asString(atoms::GET_LOCATION).c_str()); | 259 atoms::asString(atoms::GET_LOCATION).c_str()); |
260 | 260 |
261 ListValue args; | 261 ListValue args; |
262 args.Append(element.ToValue()); | 262 args.Append(element.ToValue()); |
263 | 263 |
264 Value* result = NULL; | 264 Value* result = NULL; |
265 Error* error = session_->ExecuteScript(script, &args, &result); | 265 Error* error = session_->ExecuteScript(script, &args, &result); |
266 if (error) { | 266 if (error) { |
267 response->SetError(error); | 267 response->SetError(error); |
268 return; | 268 return; |
269 } | 269 } |
270 response->SetValue(result); | 270 response->SetValue(result); |
271 } | 271 } |
272 | 272 |
273 ///////////////////// ElementLocationInViewCommand //////////////////// | 273 ///////////////////// ElementLocationInViewCommand //////////////////// |
274 | 274 |
275 ElementLocationInViewCommand::ElementLocationInViewCommand( | 275 ElementLocationInViewCommand::ElementLocationInViewCommand( |
276 const std::vector<std::string>& path_segments, | 276 const std::vector<std::string>& path_segments, |
277 DictionaryValue* parameters) | 277 const DictionaryValue* parameters) |
278 : WebElementCommand(path_segments, parameters) {} | 278 : WebElementCommand(path_segments, parameters) {} |
279 | 279 |
280 ElementLocationInViewCommand::~ElementLocationInViewCommand() {} | 280 ElementLocationInViewCommand::~ElementLocationInViewCommand() {} |
281 | 281 |
282 bool ElementLocationInViewCommand::DoesGet() { | 282 bool ElementLocationInViewCommand::DoesGet() { |
283 return true; | 283 return true; |
284 } | 284 } |
285 | 285 |
286 void ElementLocationInViewCommand::ExecuteGet(Response* const response) { | 286 void ElementLocationInViewCommand::ExecuteGet(Response* const response) { |
287 Point location; | 287 Point location; |
288 Error* error = session_->GetElementLocationInView(element, &location); | 288 Error* error = session_->GetElementLocationInView(element, &location); |
289 if (error) { | 289 if (error) { |
290 response->SetError(error); | 290 response->SetError(error); |
291 return; | 291 return; |
292 } | 292 } |
293 DictionaryValue* coord_dict = new DictionaryValue(); | 293 DictionaryValue* coord_dict = new DictionaryValue(); |
294 coord_dict->SetInteger("x", location.x()); | 294 coord_dict->SetInteger("x", location.x()); |
295 coord_dict->SetInteger("y", location.y()); | 295 coord_dict->SetInteger("y", location.y()); |
296 response->SetValue(coord_dict); | 296 response->SetValue(coord_dict); |
297 } | 297 } |
298 | 298 |
299 ///////////////////// ElementNameCommand //////////////////// | 299 ///////////////////// ElementNameCommand //////////////////// |
300 | 300 |
301 ElementNameCommand::ElementNameCommand( | 301 ElementNameCommand::ElementNameCommand( |
302 const std::vector<std::string>& path_segments, | 302 const std::vector<std::string>& path_segments, |
303 DictionaryValue* parameters) | 303 const DictionaryValue* parameters) |
304 : WebElementCommand(path_segments, parameters) {} | 304 : WebElementCommand(path_segments, parameters) {} |
305 | 305 |
306 ElementNameCommand::~ElementNameCommand() {} | 306 ElementNameCommand::~ElementNameCommand() {} |
307 | 307 |
308 bool ElementNameCommand::DoesGet() { | 308 bool ElementNameCommand::DoesGet() { |
309 return true; | 309 return true; |
310 } | 310 } |
311 | 311 |
312 void ElementNameCommand::ExecuteGet(Response* const response) { | 312 void ElementNameCommand::ExecuteGet(Response* const response) { |
313 std::string tag_name; | 313 std::string tag_name; |
314 Error* error = session_->GetElementTagName( | 314 Error* error = session_->GetElementTagName( |
315 session_->current_target(), element, &tag_name); | 315 session_->current_target(), element, &tag_name); |
316 if (error) { | 316 if (error) { |
317 response->SetError(error); | 317 response->SetError(error); |
318 return; | 318 return; |
319 } | 319 } |
320 response->SetValue(Value::CreateStringValue(tag_name)); | 320 response->SetValue(Value::CreateStringValue(tag_name)); |
321 } | 321 } |
322 | 322 |
323 ///////////////////// ElementSelectedCommand //////////////////// | 323 ///////////////////// ElementSelectedCommand //////////////////// |
324 | 324 |
325 ElementSelectedCommand::ElementSelectedCommand( | 325 ElementSelectedCommand::ElementSelectedCommand( |
326 const std::vector<std::string>& path_segments, | 326 const std::vector<std::string>& path_segments, |
327 DictionaryValue* parameters) | 327 const DictionaryValue* parameters) |
328 : WebElementCommand(path_segments, parameters) {} | 328 : WebElementCommand(path_segments, parameters) {} |
329 | 329 |
330 ElementSelectedCommand::~ElementSelectedCommand() {} | 330 ElementSelectedCommand::~ElementSelectedCommand() {} |
331 | 331 |
332 bool ElementSelectedCommand::DoesGet() { | 332 bool ElementSelectedCommand::DoesGet() { |
333 return true; | 333 return true; |
334 } | 334 } |
335 | 335 |
336 bool ElementSelectedCommand::DoesPost() { | 336 bool ElementSelectedCommand::DoesPost() { |
337 return true; | 337 return true; |
(...skipping 16 matching lines...) Expand all Loading... |
354 if (error) { | 354 if (error) { |
355 response->SetError(error); | 355 response->SetError(error); |
356 return; | 356 return; |
357 } | 357 } |
358 } | 358 } |
359 | 359 |
360 ///////////////////// ElementSizeCommand //////////////////// | 360 ///////////////////// ElementSizeCommand //////////////////// |
361 | 361 |
362 ElementSizeCommand::ElementSizeCommand( | 362 ElementSizeCommand::ElementSizeCommand( |
363 const std::vector<std::string>& path_segments, | 363 const std::vector<std::string>& path_segments, |
364 DictionaryValue* parameters) | 364 const DictionaryValue* parameters) |
365 : WebElementCommand(path_segments, parameters) {} | 365 : WebElementCommand(path_segments, parameters) {} |
366 | 366 |
367 ElementSizeCommand::~ElementSizeCommand() {} | 367 ElementSizeCommand::~ElementSizeCommand() {} |
368 | 368 |
369 bool ElementSizeCommand::DoesGet() { | 369 bool ElementSizeCommand::DoesGet() { |
370 return true; | 370 return true; |
371 } | 371 } |
372 | 372 |
373 void ElementSizeCommand::ExecuteGet(Response* const response) { | 373 void ElementSizeCommand::ExecuteGet(Response* const response) { |
374 Size size; | 374 Size size; |
375 Error* error = session_->GetElementSize( | 375 Error* error = session_->GetElementSize( |
376 session_->current_target(), element, &size); | 376 session_->current_target(), element, &size); |
377 if (error) { | 377 if (error) { |
378 response->SetError(error); | 378 response->SetError(error); |
379 return; | 379 return; |
380 } | 380 } |
381 DictionaryValue* dict = new DictionaryValue(); | 381 DictionaryValue* dict = new DictionaryValue(); |
382 dict->SetInteger("width", size.width()); | 382 dict->SetInteger("width", size.width()); |
383 dict->SetInteger("height", size.height()); | 383 dict->SetInteger("height", size.height()); |
384 response->SetValue(dict); | 384 response->SetValue(dict); |
385 } | 385 } |
386 | 386 |
387 ///////////////////// ElementSubmitCommand //////////////////// | 387 ///////////////////// ElementSubmitCommand //////////////////// |
388 | 388 |
389 ElementSubmitCommand::ElementSubmitCommand( | 389 ElementSubmitCommand::ElementSubmitCommand( |
390 const std::vector<std::string>& path_segments, | 390 const std::vector<std::string>& path_segments, |
391 DictionaryValue* parameters) | 391 const DictionaryValue* parameters) |
392 : WebElementCommand(path_segments, parameters) {} | 392 : WebElementCommand(path_segments, parameters) {} |
393 | 393 |
394 ElementSubmitCommand::~ElementSubmitCommand() {} | 394 ElementSubmitCommand::~ElementSubmitCommand() {} |
395 | 395 |
396 bool ElementSubmitCommand::DoesPost() { | 396 bool ElementSubmitCommand::DoesPost() { |
397 return true; | 397 return true; |
398 } | 398 } |
399 | 399 |
400 void ElementSubmitCommand::ExecutePost(Response* const response) { | 400 void ElementSubmitCommand::ExecutePost(Response* const response) { |
401 std::string script = base::StringPrintf( | 401 std::string script = base::StringPrintf( |
402 "(%s).apply(null, arguments);", atoms::asString(atoms::SUBMIT).c_str()); | 402 "(%s).apply(null, arguments);", atoms::asString(atoms::SUBMIT).c_str()); |
403 | 403 |
404 ListValue args; | 404 ListValue args; |
405 args.Append(element.ToValue()); | 405 args.Append(element.ToValue()); |
406 | 406 |
407 Value* result = NULL; | 407 Value* result = NULL; |
408 Error* error = session_->ExecuteScript(script, &args, &result); | 408 Error* error = session_->ExecuteScript(script, &args, &result); |
409 if (error) { | 409 if (error) { |
410 response->SetError(error); | 410 response->SetError(error); |
411 return; | 411 return; |
412 } | 412 } |
413 response->SetValue(result); | 413 response->SetValue(result); |
414 } | 414 } |
415 | 415 |
416 ///////////////////// ElementToggleCommand //////////////////// | 416 ///////////////////// ElementToggleCommand //////////////////// |
417 | 417 |
418 ElementToggleCommand::ElementToggleCommand( | 418 ElementToggleCommand::ElementToggleCommand( |
419 const std::vector<std::string>& path_segments, | 419 const std::vector<std::string>& path_segments, |
420 DictionaryValue* parameters) | 420 const DictionaryValue* parameters) |
421 : WebElementCommand(path_segments, parameters) {} | 421 : WebElementCommand(path_segments, parameters) {} |
422 | 422 |
423 ElementToggleCommand::~ElementToggleCommand() {} | 423 ElementToggleCommand::~ElementToggleCommand() {} |
424 | 424 |
425 bool ElementToggleCommand::DoesPost() { | 425 bool ElementToggleCommand::DoesPost() { |
426 return true; | 426 return true; |
427 } | 427 } |
428 | 428 |
429 void ElementToggleCommand::ExecutePost(Response* const response) { | 429 void ElementToggleCommand::ExecutePost(Response* const response) { |
430 std::string script = base::StringPrintf( | 430 std::string script = base::StringPrintf( |
431 "return (%s).apply(null, arguments);", | 431 "return (%s).apply(null, arguments);", |
432 atoms::asString(atoms::CLICK).c_str()); | 432 atoms::asString(atoms::CLICK).c_str()); |
433 | 433 |
434 ListValue args; | 434 ListValue args; |
435 args.Append(element.ToValue()); | 435 args.Append(element.ToValue()); |
436 | 436 |
437 Value* result = NULL; | 437 Value* result = NULL; |
438 Error* error = session_->ExecuteScript(script, &args, &result); | 438 Error* error = session_->ExecuteScript(script, &args, &result); |
439 if (error) { | 439 if (error) { |
440 response->SetError(error); | 440 response->SetError(error); |
441 return; | 441 return; |
442 } | 442 } |
443 response->SetValue(result); | 443 response->SetValue(result); |
444 } | 444 } |
445 | 445 |
446 ///////////////////// ElementValueCommand //////////////////// | 446 ///////////////////// ElementValueCommand //////////////////// |
447 | 447 |
448 ElementValueCommand::ElementValueCommand( | 448 ElementValueCommand::ElementValueCommand( |
449 const std::vector<std::string>& path_segments, | 449 const std::vector<std::string>& path_segments, |
450 DictionaryValue* parameters) | 450 const DictionaryValue* parameters) |
451 : WebElementCommand(path_segments, parameters) {} | 451 : WebElementCommand(path_segments, parameters) {} |
452 | 452 |
453 ElementValueCommand::~ElementValueCommand() {} | 453 ElementValueCommand::~ElementValueCommand() {} |
454 | 454 |
455 bool ElementValueCommand::DoesGet() { | 455 bool ElementValueCommand::DoesGet() { |
456 return true; | 456 return true; |
457 } | 457 } |
458 | 458 |
459 bool ElementValueCommand::DoesPost() { | 459 bool ElementValueCommand::DoesPost() { |
460 return true; | 460 return true; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 if (scoped_value->GetAsString(&actual_value)) { | 524 if (scoped_value->GetAsString(&actual_value)) { |
525 *result = LowerCaseEqualsASCII(actual_value, value.c_str()); | 525 *result = LowerCaseEqualsASCII(actual_value, value.c_str()); |
526 } else { | 526 } else { |
527 // Note we do not handle converting a number to a string. | 527 // Note we do not handle converting a number to a string. |
528 *result = false; | 528 *result = false; |
529 } | 529 } |
530 return NULL; | 530 return NULL; |
531 } | 531 } |
532 | 532 |
533 Error* ElementValueCommand::DragAndDropFilePaths() const { | 533 Error* ElementValueCommand::DragAndDropFilePaths() const { |
534 ListValue* path_list; | 534 const ListValue* path_list; |
535 if (!GetListParameter("value", &path_list)) | 535 if (!GetListParameter("value", &path_list)) |
536 return new Error(kBadRequest, "Missing or invalid 'value' parameter"); | 536 return new Error(kBadRequest, "Missing or invalid 'value' parameter"); |
537 | 537 |
538 // Compress array into single string. | 538 // Compress array into single string. |
539 FilePath::StringType paths_string; | 539 FilePath::StringType paths_string; |
540 for (size_t i = 0; i < path_list->GetSize(); ++i) { | 540 for (size_t i = 0; i < path_list->GetSize(); ++i) { |
541 FilePath::StringType path_part; | 541 FilePath::StringType path_part; |
542 if (!path_list->GetString(i, &path_part)) { | 542 if (!path_list->GetString(i, &path_part)) { |
543 return new Error( | 543 return new Error( |
544 kBadRequest, | 544 kBadRequest, |
(...skipping 27 matching lines...) Expand all Loading... |
572 | 572 |
573 Point location; | 573 Point location; |
574 error = session_->GetClickableLocation(element, &location); | 574 error = session_->GetClickableLocation(element, &location); |
575 if (error) | 575 if (error) |
576 return error; | 576 return error; |
577 | 577 |
578 return session_->DragAndDropFilePaths(location, paths); | 578 return session_->DragAndDropFilePaths(location, paths); |
579 } | 579 } |
580 | 580 |
581 Error* ElementValueCommand::SendKeys() const { | 581 Error* ElementValueCommand::SendKeys() const { |
582 ListValue* key_list; | 582 const ListValue* key_list; |
583 if (!GetListParameter("value", &key_list)) { | 583 if (!GetListParameter("value", &key_list)) { |
584 return new Error(kBadRequest, "Missing or invalid 'value' parameter"); | 584 return new Error(kBadRequest, "Missing or invalid 'value' parameter"); |
585 } | 585 } |
586 | 586 |
587 // Flatten the given array of strings into one. | 587 // Flatten the given array of strings into one. |
588 string16 keys; | 588 string16 keys; |
589 Error* error = FlattenStringArray(key_list, &keys); | 589 Error* error = FlattenStringArray(key_list, &keys); |
590 if (error) | 590 if (error) |
591 return error; | 591 return error; |
592 | 592 |
593 return session_->SendKeys(element, keys); | 593 return session_->SendKeys(element, keys); |
594 } | 594 } |
595 | 595 |
596 ///////////////////// ElementTextCommand //////////////////// | 596 ///////////////////// ElementTextCommand //////////////////// |
597 | 597 |
598 ElementTextCommand::ElementTextCommand( | 598 ElementTextCommand::ElementTextCommand( |
599 const std::vector<std::string>& path_segments, | 599 const std::vector<std::string>& path_segments, |
600 DictionaryValue* parameters) | 600 const DictionaryValue* parameters) |
601 : WebElementCommand(path_segments, parameters) {} | 601 : WebElementCommand(path_segments, parameters) {} |
602 | 602 |
603 ElementTextCommand::~ElementTextCommand() {} | 603 ElementTextCommand::~ElementTextCommand() {} |
604 | 604 |
605 bool ElementTextCommand::DoesGet() { | 605 bool ElementTextCommand::DoesGet() { |
606 return true; | 606 return true; |
607 } | 607 } |
608 | 608 |
609 void ElementTextCommand::ExecuteGet(Response* const response) { | 609 void ElementTextCommand::ExecuteGet(Response* const response) { |
610 Value* unscoped_result = NULL; | 610 Value* unscoped_result = NULL; |
(...skipping 12 matching lines...) Expand all Loading... |
623 return; | 623 return; |
624 } | 624 } |
625 if (!result->IsType(Value::TYPE_STRING)) { | 625 if (!result->IsType(Value::TYPE_STRING)) { |
626 response->SetError(new Error(kUnknownError, "Result is not string type")); | 626 response->SetError(new Error(kUnknownError, "Result is not string type")); |
627 return; | 627 return; |
628 } | 628 } |
629 response->SetValue(result.release()); | 629 response->SetValue(result.release()); |
630 } | 630 } |
631 | 631 |
632 } // namespace webdriver | 632 } // namespace webdriver |
OLD | NEW |