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

Unified Diff: chrome/test/webdriver/session.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 | « chrome/test/webdriver/session.h ('k') | chrome/test/webdriver/test/WEBDRIVER_TESTS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/session.cc
diff --git a/chrome/test/webdriver/session.cc b/chrome/test/webdriver/session.cc
index 8cb01f9ad5f74373958073876399efd25c1bb831..1683ef7422a86beaa0bc07f301b9b10fdbd853aa 100644
--- a/chrome/test/webdriver/session.cc
+++ b/chrome/test/webdriver/session.cc
@@ -918,11 +918,33 @@ Error* Session::IsElementEnabled(const FrameId& frame_id,
return NULL;
}
-Error* Session::SelectOptionElement(const FrameId& frame_id,
- const WebElementId& element) {
+Error* Session::IsOptionElementSelected(const FrameId& frame_id,
+ const WebElementId& element,
+ bool* is_selected) {
+ ListValue args;
+ args.Append(element.ToValue());
+
+ std::string script = base::StringPrintf(
+ "return (%s).apply(null, arguments);", atoms::IS_SELECTED);
+
+ Value* result = NULL;
+ Error* error = ExecuteScript(frame_id, script, &args, &result);
+ if (error)
+ return error;
+ scoped_ptr<Value> scoped_result(result);
+ if (!result->GetAsBoolean(is_selected)) {
+ return new Error(kUnknownError, "isSelected atom returned non-boolean: " +
+ JsonStringify(result));
+ }
+ return NULL;
+}
+
+Error* Session::SetOptionElementSelected(const FrameId& frame_id,
+ const WebElementId& element,
+ bool selected) {
ListValue args;
args.Append(element.ToValue());
- args.Append(Value::CreateBooleanValue(true));
+ args.Append(Value::CreateBooleanValue(selected));
std::string script = base::StringPrintf(
"return (%s).apply(null, arguments);", atoms::SET_SELECTED);
@@ -933,6 +955,16 @@ Error* Session::SelectOptionElement(const FrameId& frame_id,
return error;
}
+Error* Session::ToggleOptionElement(const FrameId& frame_id,
+ const WebElementId& element) {
+ bool is_selected;
+ Error* error = IsOptionElementSelected(frame_id, element, &is_selected);
+ if (error)
+ return error;
+
+ return SetOptionElementSelected(frame_id, element, !is_selected);
+}
+
Error* Session::GetElementTagName(const FrameId& frame_id,
const WebElementId& element,
std::string* tag_name) {
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | chrome/test/webdriver/test/WEBDRIVER_TESTS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698