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

Unified Diff: chrome/test/chromedriver/commands.cc

Issue 11884058: [chromedriver] Implement commands: findChildElement, findChildElements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
Index: chrome/test/chromedriver/commands.cc
diff --git a/chrome/test/chromedriver/commands.cc b/chrome/test/chromedriver/commands.cc
index f64fa33ab8943af495331c102da9a526c2438a57..c0b429e1834b74de72bf3ff7480cd86566db7171 100644
--- a/chrome/test/chromedriver/commands.cc
+++ b/chrome/test/chromedriver/commands.cc
@@ -22,6 +22,7 @@ namespace {
Status FindElementByJs(
bool only_one,
+ bool has_root_element,
Session* session,
const base::DictionaryValue& params,
scoped_ptr<base::Value>* value) {
@@ -31,17 +32,9 @@ Status FindElementByJs(
std::string target;
if (!params.GetString("value", &target))
return Status(kUnknownError, "'value' must be a string");
-
- if (strategy == "class name")
- strategy = "className";
- else if (strategy == "css selector")
- strategy = "css";
- else if (strategy == "link text")
- strategy = "linkText";
- else if (strategy == "partial link text")
- strategy = "partialLinkText";
- else if (strategy == "tag name")
- strategy = "tagName";
+ std::string root_element;
+ if (has_root_element && !params.GetString("id", &root_element))
chrisgao (Use stgao instead) 2013/01/15 20:53:59 In the webdriver Json protocol(http://code.google.
kkania 2013/01/15 22:24:36 Does this actually work with the Java bindings?
+ return Status(kUnknownError, "'id' of root element must be a string");
std::string script;
if (only_one)
@@ -52,6 +45,11 @@ Status FindElementByJs(
locator->SetString(strategy, target);
base::ListValue arguments;
arguments.Append(locator.release());
+ if (has_root_element) {
+ scoped_ptr<base::DictionaryValue> id(new base::DictionaryValue());
+ id->SetString("ELEMENT", root_element);
+ arguments.Append(id.release());
+ }
base::Time start_time = base::Time::Now();
while (true) {
@@ -247,14 +245,28 @@ Status ExecuteFindElement(
Session* session,
const base::DictionaryValue& params,
scoped_ptr<base::Value>* value) {
- return FindElementByJs(true, session, params, value);
+ return FindElementByJs(true, false, session, params, value);
}
Status ExecuteFindElements(
Session* session,
const base::DictionaryValue& params,
scoped_ptr<base::Value>* value) {
- return FindElementByJs(false, session, params, value);
+ return FindElementByJs(false, false, session, params, value);
+}
+
+Status ExecuteFindChildElement(
+ Session* session,
+ const base::DictionaryValue& params,
+ scoped_ptr<base::Value>* value) {
+ return FindElementByJs(true, true, session, params, value);
+}
+
+Status ExecuteFindChildElements(
+ Session* session,
+ const base::DictionaryValue& params,
+ scoped_ptr<base::Value>* value) {
+ return FindElementByJs(false, true, session, params, value);
}
Status ExecuteSetTimeout(

Powered by Google App Engine
This is Rietveld 408576698