Commit 1bbe3452 authored by chrisgao@chromium.org's avatar chrisgao@chromium.org

[chromedriver] Wait for the element to be visible before SendKeys.


Review URL: https://chromiumcodereview.appspot.com/13981003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193430 0039d316-1c4b-4281-b951-d872f2087c98
parent 77e775b2
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/test/chromedriver/basic_types.h" #include "chrome/test/chromedriver/basic_types.h"
#include "chrome/test/chromedriver/chrome/chrome.h" #include "chrome/test/chromedriver/chrome/chrome.h"
...@@ -31,14 +33,22 @@ Status SendKeysToElement( ...@@ -31,14 +33,22 @@ Status SendKeysToElement(
const std::string& element_id, const std::string& element_id,
const ListValue* key_list) { const ListValue* key_list) {
bool is_displayed = false; bool is_displayed = false;
Status status = IsElementDisplayed( base::Time start_time = base::Time::Now();
session, web_view, element_id, true, &is_displayed); while (true) {
if (status.IsError()) Status status = IsElementDisplayed(
return status; session, web_view, element_id, true, &is_displayed);
if (!is_displayed) if (status.IsError())
return Status(kElementNotVisible); 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; 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()) if (status.IsError())
return status; return status;
if (!is_enabled) if (!is_enabled)
......
...@@ -55,7 +55,6 @@ _REVISION_NEGATIVE_FILTER['HEAD'] = [ ...@@ -55,7 +55,6 @@ _REVISION_NEGATIVE_FILTER['HEAD'] = [
'GetLogsTest.logBufferShouldBeResetAfterEachGetLogCall', 'GetLogsTest.logBufferShouldBeResetAfterEachGetLogCall',
'GetLogsTest.turningOffLogShouldMeanNoLogMessages', 'GetLogsTest.turningOffLogShouldMeanNoLogMessages',
'I18nTest.testShouldBeAbleToActivateIMEEngine', 'I18nTest.testShouldBeAbleToActivateIMEEngine',
'ImplicitWaitTest.testShouldImplicitlyWaitForAnElementToBeVisibleBeforeInteracting',
# Broken because AddWebStorage.java is broken. # Broken because AddWebStorage.java is broken.
'LocalStorageTest.*', 'LocalStorageTest.*',
'LocationContextTest.*', 'LocationContextTest.*',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment