| Index: chrome/test/webdriver/session.cc
|
| diff --git a/chrome/test/webdriver/session.cc b/chrome/test/webdriver/session.cc
|
| index ebb7fae51ab67c7e07f8124585ccd6f4ba31935d..e3fd430449ec066dc2f3f6583a0fdb7859e76663 100644
|
| --- a/chrome/test/webdriver/session.cc
|
| +++ b/chrome/test/webdriver/session.cc
|
| @@ -173,12 +173,19 @@ ErrorCode Session::ExecuteScript(const std::string& script,
|
| }
|
|
|
| ErrorCode Session::SendKeys(const WebElementId& element, const string16& keys) {
|
| + bool is_displayed;
|
| + ErrorCode code = IsElementDisplayed(current_target_, element, &is_displayed);
|
| + if (code != kSuccess)
|
| + return code;
|
| + if (!is_displayed)
|
| + return kElementNotVisible;
|
| +
|
| ListValue args;
|
| args.Append(element.ToValue());
|
| // TODO(jleyba): Update this to use the correct atom.
|
| std::string script = "document.activeElement.blur();arguments[0].focus();";
|
| Value* unscoped_result = NULL;
|
| - ErrorCode code = ExecuteScript(script, &args, &unscoped_result);
|
| + code = ExecuteScript(script, &args, &unscoped_result);
|
| scoped_ptr<Value> result(unscoped_result);
|
| if (code != kSuccess) {
|
| LOG(ERROR) << "Failed to focus element before sending keys";
|
| @@ -278,7 +285,7 @@ bool Session::GetTabTitle(std::string* tab_title) {
|
| return success;
|
| }
|
|
|
| -void Session::MouseClick(const gfx::Point& click,
|
| +bool Session::MouseClick(const gfx::Point& click,
|
| automation::MouseButton button) {
|
| bool success = false;
|
| RunSessionTask(NewRunnableMethod(
|
| @@ -288,6 +295,7 @@ void Session::MouseClick(const gfx::Point& click,
|
| click,
|
| button,
|
| &success));
|
| + return success;
|
| }
|
|
|
| bool Session::MouseMove(const gfx::Point& location) {
|
| @@ -649,6 +657,26 @@ ErrorCode Session::GetElementBorder(const FrameId& frame_id,
|
| return kSuccess;
|
| }
|
|
|
| +ErrorCode Session::IsElementDisplayed(const FrameId& frame_id,
|
| + const WebElementId& element,
|
| + bool* is_displayed) {
|
| + std::string script = base::StringPrintf(
|
| + "return (%s).apply(null, arguments);", atoms::IS_DISPLAYED);
|
| + ListValue args;
|
| + args.Append(element.ToValue());
|
| +
|
| + Value* unscoped_result = NULL;
|
| + ErrorCode code = ExecuteScript(frame_id, script, &args, &unscoped_result);
|
| + scoped_ptr<Value> result(unscoped_result);
|
| + if (code != kSuccess)
|
| + return code;
|
| + if (!result->GetAsBoolean(is_displayed)) {
|
| + LOG(ERROR) << "IsDisplayed atom returned non boolean";
|
| + return kUnknownError;
|
| + }
|
| + return kSuccess;
|
| +}
|
| +
|
| bool Session::WaitForAllTabsToStopLoading() {
|
| if (!automation_.get())
|
| return true;
|
|
|