Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: chrome/test/chromedriver/element_commands.cc

Issue 13981003: [chromedriver] Wait for the element to be visible before SendKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/chromedriver/test_expectations » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/element_commands.cc
diff --git a/chrome/test/chromedriver/element_commands.cc b/chrome/test/chromedriver/element_commands.cc
index 395da598e2d09086e9ecad91a25eccb292faa821..8fb39b9ccbadfa0adb4481d1a72055d4bbc44531 100644
--- a/chrome/test/chromedriver/element_commands.cc
+++ b/chrome/test/chromedriver/element_commands.cc
@@ -11,6 +11,8 @@
#include "base/files/file_path.h"
#include "base/stringprintf.h"
#include "base/strings/string_split.h"
+#include "base/threading/platform_thread.h"
+#include "base/time.h"
#include "base/values.h"
#include "chrome/test/chromedriver/basic_types.h"
#include "chrome/test/chromedriver/chrome/chrome.h"
@@ -31,14 +33,22 @@ Status SendKeysToElement(
const std::string& element_id,
const ListValue* key_list) {
bool is_displayed = false;
- Status status = IsElementDisplayed(
- session, web_view, element_id, true, &is_displayed);
- if (status.IsError())
- return status;
- if (!is_displayed)
- return Status(kElementNotVisible);
+ base::Time start_time = base::Time::Now();
+ while (true) {
+ Status status = IsElementDisplayed(
+ session, web_view, element_id, true, &is_displayed);
+ if (status.IsError())
+ return status;
+ if (is_displayed)
+ break;
+ if ((base::Time::Now() - start_time).InMilliseconds() >=
+ session->implicit_wait) {
+ return Status(kElementNotVisible);
+ }
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
+ }
bool is_enabled = false;
- status = IsElementEnabled(session, web_view, element_id, &is_enabled);
+ Status status = IsElementEnabled(session, web_view, element_id, &is_enabled);
if (status.IsError())
return status;
if (!is_enabled)
« no previous file with comments | « no previous file | chrome/test/chromedriver/test_expectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698