Commit 76cbefb8 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] GetElementRect should allow doubles

Currently, GetElementRect command expects all returned values (x, y,
width, height) to be integers, but in reality they can be non-integer
numbers. This CL fixes the implementation, and improves error messages.

Bug: chromedriver:2545
Change-Id: I8c01f0d7f3de530e5e54b7e698a5583b050b68a3
Reviewed-on: https://chromium-review.googlesource.com/1178759Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583851}
parent 6584d78b
...@@ -504,24 +504,24 @@ Status ExecuteGetElementRect(Session* session, ...@@ -504,24 +504,24 @@ Status ExecuteGetElementRect(Session* session,
return Status(kUnknownError, "could not convert to DictionaryValue"); return Status(kUnknownError, "could not convert to DictionaryValue");
// grab values // grab values
int x, y, width, height; double x, y, width, height;
if (!location_dict->GetInteger("x", &x)) if (!location_dict->GetDouble("x", &x))
return Status(kUnknownError, "getting size failed to return x"); return Status(kUnknownError, "x coordinate is missing in element location");
if (!location_dict->GetInteger("y", &y)) if (!location_dict->GetDouble("y", &y))
return Status(kUnknownError, "getting size failed to return y"); return Status(kUnknownError, "y coordinate is missing in element location");
if (!size_dict->GetInteger("height", &height)) if (!size_dict->GetDouble("height", &height))
return Status(kUnknownError, "getting location failed to return height"); return Status(kUnknownError, "height is missing in element size");
if (!size_dict->GetInteger("width", &width)) if (!size_dict->GetDouble("width", &width))
return Status(kUnknownError, "getting location failed to return width"); return Status(kUnknownError, "width is missing in element size");
base::DictionaryValue ret; base::DictionaryValue ret;
ret.SetInteger("x", x); ret.SetDouble("x", x);
ret.SetInteger("y", y); ret.SetDouble("y", y);
ret.SetInteger("width", width); ret.SetDouble("width", width);
ret.SetInteger("height", height); ret.SetDouble("height", height);
value->reset(ret.DeepCopy()); value->reset(ret.DeepCopy());
return Status(kOk); return Status(kOk);
} }
......
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