Commit 9139ce49 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Better handle invisible element

Fix a couple of issues related to handling of some types of
invisible elements:
* When element.getClientRects() returns an empty list, the code tries to
  use getBoundingClientRect, but the Object.assign call doesn't work
  correctly.
* Zero-size elements can't be clicked on. Return appropriate error.

These changes fix problems reported in an internal Google discussion
(https://groups.google.com/a/google.com/g/webdriver-users/c/CKv3HQCBA4o).

Change-Id: I4f9a2c42e6268441b6b3105de23bbef7b370a0c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079998
Commit-Queue: John Chen <johnchen@chromium.org>
Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Auto-Submit: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745529}
parent 4b009fa3
......@@ -555,6 +555,9 @@ Status GetElementClickableLocation(
if (status.IsError())
return status;
if (rect.Width() == 0 || rect.Height() == 0)
return Status(kElementNotInteractable, "element has zero size");
status = ScrollElementRegionIntoView(
session, web_view, target_element_id, rect,
true /* center */, element_id, location);
......
......@@ -99,8 +99,7 @@ function getElementRegion(element) {
throw new Error('shape=' + element.shape + ' is not supported');
}
} else {
boundingRect = element.getBoundingClientRect();
clientRect = Object.assign({}, boundingRect);
clientRect = boundingRect = element.getBoundingClientRect();
}
} else {
boundingRect = element.getBoundingClientRect();
......
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