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

Unified Diff: chrome/test/webdriver/commands/mouse_commands.cc

Issue 7541056: Toggle a multiple select option instead of setting it as selected when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 4 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/webdriver/commands/webelement_commands.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/commands/mouse_commands.cc
diff --git a/chrome/test/webdriver/commands/mouse_commands.cc b/chrome/test/webdriver/commands/mouse_commands.cc
index 0a8724d66b993acdf6d084ac9b900fb85e52ec5c..70339b8e1420d80e9de58c6ca594cba749631abf 100644
--- a/chrome/test/webdriver/commands/mouse_commands.cc
+++ b/chrome/test/webdriver/commands/mouse_commands.cc
@@ -8,6 +8,7 @@
#include "chrome/common/automation_constants.h"
#include "chrome/test/webdriver/commands/response.h"
#include "chrome/test/webdriver/session.h"
+#include "chrome/test/webdriver/utility_functions.h"
#include "chrome/test/webdriver/web_element_id.h"
#include "chrome/test/webdriver/webdriver_error.h"
#include "ui/gfx/point.h"
@@ -44,7 +45,38 @@ void MoveAndClickCommand::ExecutePost(Response* response) {
}
if (tag_name == "option") {
- error = session_->SelectOptionElement(session_->current_target(), element);
+ const char* kCanOptionBeToggledScript =
+ "return (function(option) {"
+ " var select = option.parentElement;"
+ " if (!select || select.tagName.toLowerCase() != 'select')"
+ " throw new Error('Option element is not in a select');"
+ " return select.multiple;"
+ "}).apply(null, arguments);";
+ ListValue args;
+ args.Append(element.ToValue());
+ Value* value = NULL;
+ error = session_->ExecuteScript(
+ session_->current_target(), kCanOptionBeToggledScript, &args, &value);
+ if (error) {
+ response->SetError(error);
+ return;
+ }
+ scoped_ptr<Value> scoped_value(value);
+ bool can_be_toggled;
+ if (!value->GetAsBoolean(&can_be_toggled)) {
+ response->SetError(
+ new Error(kUnknownError, "canOptionBeToggled returned non-boolean: " +
+ JsonStringify(value)));
+ return;
+ }
+
+ if (can_be_toggled) {
+ error = session_->ToggleOptionElement(
+ session_->current_target(), element);
+ } else {
+ error = session_->SetOptionElementSelected(
+ session_->current_target(), element, true);
+ }
} else {
gfx::Point location;
error = session_->GetClickableLocation(element, &location);
« no previous file with comments | « no previous file | chrome/test/webdriver/commands/webelement_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698