| 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 #include "chrome/test/webdriver/commands/find_element_commands.h" | 5 #include "chrome/test/webdriver/commands/find_element_commands.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 error = session_->ExecuteScript(jscript, args.get(), &result); | 106 error = session_->ExecuteScript(jscript, args.get(), &result); |
| 107 if (error == kSuccess) { | 107 if (error == kSuccess) { |
| 108 // If searching for many elements, make sure we found at least one before | 108 // If searching for many elements, make sure we found at least one before |
| 109 // stopping. | 109 // stopping. |
| 110 done = find_one_element_ || | 110 done = find_one_element_ || |
| 111 (result->GetType() == Value::TYPE_LIST && | 111 (result->GetType() == Value::TYPE_LIST && |
| 112 static_cast<ListValue*>(result)->GetSize() > 0); | 112 static_cast<ListValue*>(result)->GetSize() > 0); |
| 113 } else if (error != kNoSuchElement) { | 113 } else if (error != kNoSuchElement) { |
| 114 SET_WEBDRIVER_ERROR(response, "Internal error in find_element atom", | 114 SET_WEBDRIVER_SCREENSHOT_ERROR(response, |
| 115 kInternalServerError); | 115 session_, |
| 116 "Internal error in find_element atom", |
| 117 kInternalServerError); |
| 116 return; | 118 return; |
| 117 } | 119 } |
| 118 | 120 |
| 119 int64 elapsed_time = (base::Time::Now() - start_time).InMilliseconds(); | 121 int64 elapsed_time = (base::Time::Now() - start_time).InMilliseconds(); |
| 120 done = done || elapsed_time > session_->implicit_wait(); | 122 done = done || elapsed_time > session_->implicit_wait(); |
| 121 base::PlatformThread::Sleep(50); // Prevent a busy loop that eats the cpu. | 123 base::PlatformThread::Sleep(50); // Prevent a busy loop that eats the cpu. |
| 122 } | 124 } |
| 123 | 125 |
| 124 response->SetValue(result); | 126 response->SetValue(result); |
| 125 response->SetStatus(error); | 127 response->SetStatus(error); |
| 126 } | 128 } |
| 127 | 129 |
| 128 bool FindElementCommand::RequiresValidTab() { | 130 bool FindElementCommand::RequiresValidTab() { |
| 129 return false; | 131 return false; |
| 130 } | 132 } |
| 131 | 133 |
| 132 } // namespace webdriver | 134 } // namespace webdriver |
| OLD | NEW |