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( |