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 @@
#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)
......
......@@ -55,7 +55,6 @@ _REVISION_NEGATIVE_FILTER['HEAD'] = [
'GetLogsTest.logBufferShouldBeResetAfterEachGetLogCall',
'GetLogsTest.turningOffLogShouldMeanNoLogMessages',
'I18nTest.testShouldBeAbleToActivateIMEEngine',
'ImplicitWaitTest.testShouldImplicitlyWaitForAnElementToBeVisibleBeforeInteracting',
# Broken because AddWebStorage.java is broken.
'LocalStorageTest.*',
'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