OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 #include <string> |
| 6 |
| 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/test/webdriver/commands/implicit_wait_command.h" |
| 9 |
| 10 namespace webdriver { |
| 11 |
| 12 bool ImplicitWaitCommand::Init(Response* const response) { |
| 13 if (!(WebDriverCommand::Init(response))) { |
| 14 SET_WEBDRIVER_ERROR(response, "Failure on Init for find element", |
| 15 kInternalServerError); |
| 16 return false; |
| 17 } |
| 18 |
| 19 // Record the requested wait time. |
| 20 if (!GetIntegerParameter("ms", &ms_to_wait_)) { |
| 21 SET_WEBDRIVER_ERROR(response, "Request missing ms parameter", |
| 22 kBadRequest); |
| 23 return false; |
| 24 } |
| 25 |
| 26 return true; |
| 27 } |
| 28 |
| 29 void ImplicitWaitCommand::ExecutePost(Response* const response) { |
| 30 // Validate the wait time before setting it to the session. |
| 31 if (ms_to_wait_ < 0) { |
| 32 SET_WEBDRIVER_ERROR(response, "Wait must be non-negative", |
| 33 kBadRequest); |
| 34 return; |
| 35 } |
| 36 |
| 37 session_->set_implicit_wait(ms_to_wait_); |
| 38 LOG(INFO) << "Implicit wait set to: " << ms_to_wait_ << " ms"; |
| 39 |
| 40 response->set_value(new StringValue("success")); |
| 41 response->set_status(kSuccess); |
| 42 } |
| 43 |
| 44 } // namespace webdriver |
| 45 |
OLD | NEW |