Commit f393ab48 authored by Tatiana Buldina's avatar Tatiana Buldina Committed by Commit Bot

[ChromeDriver] XML special case in Get Element CSS Value

Bug: chromedriver:1994
Change-Id: Ic15edd6634d5a8cc118703a86155a90eda602a7d
Reviewed-on: https://chromium-review.googlesource.com/c/1292407Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Tatiana Buldina <buldina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605490}
parent e61e5c03
...@@ -603,20 +603,29 @@ Status ExecuteGetElementAttribute(Session* session, ...@@ -603,20 +603,29 @@ Status ExecuteGetElementAttribute(Session* session,
} }
Status ExecuteGetElementValueOfCSSProperty( Status ExecuteGetElementValueOfCSSProperty(
Session* session, Session* session,
WebView* web_view, WebView* web_view,
const std::string& element_id, const std::string& element_id,
const base::DictionaryValue& params, const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value) { std::unique_ptr<base::Value>* value) {
std::string property_name; bool is_xml = false;
if (!params.GetString("propertyName", &property_name)) Status status = IsDocumentTypeXml(session, web_view, &is_xml);
return Status(kUnknownError, "missing 'propertyName'");
std::string property_value;
Status status = GetElementEffectiveStyle(
session, web_view, element_id, property_name, &property_value);
if (status.IsError()) if (status.IsError())
return status; return status;
value->reset(new base::Value(property_value));
if (is_xml) {
value->reset(new base::Value(""));
} else {
std::string property_name;
if (!params.GetString("propertyName", &property_name))
return Status(kUnknownError, "missing 'propertyName'");
std::string property_value;
status = GetElementEffectiveStyle(
session, web_view, element_id, property_name, &property_value);
if (status.IsError())
return status;
value->reset(new base::Value(property_value));
}
return Status(kOk); return Status(kOk);
} }
......
...@@ -358,6 +358,25 @@ Status IsElementFocused( ...@@ -358,6 +358,25 @@ Status IsElementFocused(
return Status(kOk); return Status(kOk);
} }
Status IsDocumentTypeXml(
Session* session,
WebView* web_view,
bool* is_xml_document) {
std::unique_ptr<base::Value> contentType;
Status status = web_view->EvaluateScript(
session->GetCurrentFrameId(),
"document.contentType", &contentType);
if (status.IsError())
return status;
if (base::LowerCaseEqualsASCII(contentType->GetString(),
"text/xml"))
*is_xml_document = true;
else
*is_xml_document = false;
return Status(kOk);
}
Status GetElementAttribute(Session* session, Status GetElementAttribute(Session* session,
WebView* web_view, WebView* web_view,
const std::string& element_id, const std::string& element_id,
......
...@@ -45,6 +45,11 @@ Status IsElementFocused( ...@@ -45,6 +45,11 @@ Status IsElementFocused(
const std::string& element_id, const std::string& element_id,
bool* is_focused); bool* is_focused);
Status IsDocumentTypeXml(
Session* session,
WebView* web_view,
bool* is_xml_document);
Status GetElementAttribute(Session* session, Status GetElementAttribute(Session* session,
WebView* web_view, WebView* web_view,
const std::string& element_id, const std::string& element_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment