Skip to content

Commit ecc3dd0

Browse files
committed
Use elementFromPoint for IE driver in determining obscured elements
This is in direct violation of the algorithm specified in the W3C WebDriver Specification, but it fixes a class of IE-specific bugs that present themselves when using elementsFromPoint. This is used to shortcut the use of elementsFromPoint if it is not necessary.
1 parent 9ad2f48 commit ecc3dd0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cpp/iedriver/Element.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,14 @@ bool Element::IsObscured(LocationInfo* click_location,
280280
y = top + (height / 2);
281281
}
282282

283+
CComPtr<IHTMLElement> element_hit;
284+
hr = doc->elementFromPoint(x, y, &element_hit);
285+
if (SUCCEEDED(hr) && element_.IsEqualObject(element_hit)) {
286+
// Short circuit the use of elementsFromPoint if we don't
287+
// have to use it.
288+
return false;
289+
}
290+
283291
CComPtr<IHTMLDocument8> elements_doc;
284292
hr = doc.QueryInterface<IHTMLDocument8>(&elements_doc);
285293
if (FAILED(hr)) {
@@ -311,7 +319,7 @@ bool Element::IsObscured(LocationInfo* click_location,
311319

312320
bool is_list_element_displayed;
313321
Element element_wrapper(element_in_list,
314-
this->containing_window_handle_);
322+
this->containing_window_handle_);
315323
status_code = element_wrapper.IsDisplayed(false,
316324
&is_list_element_displayed);
317325
if (is_list_element_displayed) {

0 commit comments

Comments
 (0)