summaryrefslogtreecommitdiffstats
path: root/chrome/test/webdriver/commands
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/webdriver/commands')
-rw-r--r--chrome/test/webdriver/commands/mouse_commands.cc29
-rw-r--r--chrome/test/webdriver/commands/webelement_commands.cc16
2 files changed, 30 insertions, 15 deletions
diff --git a/chrome/test/webdriver/commands/mouse_commands.cc b/chrome/test/webdriver/commands/mouse_commands.cc
index 93341ff..a802a98 100644
--- a/chrome/test/webdriver/commands/mouse_commands.cc
+++ b/chrome/test/webdriver/commands/mouse_commands.cc
@@ -22,9 +22,22 @@ bool MouseCommand::DoesPost() {
}
void MouseCommand::ExecutePost(Response* response) {
- // TODO(jmikhail): verify that the element is visible
+ bool is_displayed;
+ ErrorCode code = session_->IsElementDisplayed(
+ session_->current_target(), element, &is_displayed);
+ if (code != kSuccess) {
+ SET_WEBDRIVER_ERROR(response, "Failed to determine element visibility",
+ code);
+ return;
+ }
+ if (!is_displayed) {
+ SET_WEBDRIVER_ERROR(response, "Element must be displayed",
+ kElementNotVisible);
+ return;
+ }
+
gfx::Point location;
- ErrorCode code = session_->GetElementLocationInView(element, &location);
+ code = session_->GetElementLocationInView(element, &location);
if (code != kSuccess) {
SET_WEBDRIVER_ERROR(response, "Failed to compute element location.",
code);
@@ -39,17 +52,18 @@ void MouseCommand::ExecutePost(Response* response) {
}
location.Offset(size.width() / 2, size.height() / 2);
+ bool success = false;
switch (cmd_) {
case kClick:
VLOG(1) << "Mouse click at: (" << location.x() << ", "
<< location.y() << ")" << std::endl;
- session_->MouseClick(location, automation::kLeftButton);
+ success = session_->MouseClick(location, automation::kLeftButton);
break;
case kHover:
VLOG(1) << "Mouse hover at: (" << location.x() << ", "
<< location.y() << ")" << std::endl;
- session_->MouseMove(location);
+ success = session_->MouseMove(location);
break;
case kDrag: {
@@ -65,7 +79,7 @@ void MouseCommand::ExecutePost(Response* response) {
<< "(" << location.x() << ", " << location.y() << ") "
<< "to: (" << drag_to.x() << ", " << drag_to.y() << ")"
<< std::endl;
- session_->MouseDrag(location, drag_to);
+ success = session_->MouseDrag(location, drag_to);
break;
}
@@ -74,6 +88,11 @@ void MouseCommand::ExecutePost(Response* response) {
return;
}
+ if (!success) {
+ SET_WEBDRIVER_ERROR(response, "Performing mouse operation failed",
+ kUnknownError);
+ return;
+ }
response->SetStatus(kSuccess);
}
diff --git a/chrome/test/webdriver/commands/webelement_commands.cc b/chrome/test/webdriver/commands/webelement_commands.cc
index 9471e4b..1f4e4dd 100644
--- a/chrome/test/webdriver/commands/webelement_commands.cc
+++ b/chrome/test/webdriver/commands/webelement_commands.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -155,16 +155,12 @@ bool ElementDisplayedCommand::DoesGet() {
}
void ElementDisplayedCommand::ExecuteGet(Response* const response) {
- scoped_ptr<ListValue> args(new ListValue);
- args->Append(element.ToValue());
-
- std::string script = base::StringPrintf(
- "return (%s).apply(null, arguments);", atoms::IS_DISPLAYED);
-
- Value* result = NULL;
- ErrorCode status = session_->ExecuteScript(script, args.get(), &result);
+ bool is_displayed;
+ ErrorCode status = session_->IsElementDisplayed(
+ session_->current_target(), element, &is_displayed);
+ if (status == kSuccess)
+ response->SetValue(Value::CreateBooleanValue(is_displayed));
response->SetStatus(status);
- response->SetValue(result);
}
///////////////////// ElementEnabledCommand ////////////////////