Skip to content

Commit f13f3f5

Browse files
committed
Fixing IE detection of obscured elements when top element is not displayed
Fixes issue SeleniumHQ#5668.
1 parent 61d741b commit f13f3f5

File tree

5 files changed

+34
-22
lines changed

5 files changed

+34
-22
lines changed

cpp/iedriver/Element.cpp

+25-18
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ bool Element::IsObscured(LocationInfo* click_location,
290290
return false;
291291
}
292292

293+
long top_most_element_index = -1;
293294
CComPtr<IHTMLDOMChildrenCollection> elements_hit;
294295
hr = elements_doc->elementsFromPoint(static_cast<float>(x),
295296
static_cast<float>(y),
@@ -304,26 +305,32 @@ bool Element::IsObscured(LocationInfo* click_location,
304305
CComPtr<IHTMLElement> element_in_list;
305306
hr = dispatch_in_list->QueryInterface<IHTMLElement>(&element_in_list);
306307
bool are_equal = element_in_list.IsEqualObject(this->element_);
307-
if (index == 0) {
308-
// Return the top-most element in the event we find an obscuring
309-
// element in the tree between this element and the top-most one.
310-
// Note that since it's the top-most element, it will have no
311-
// descendants, so its outerHTML property will contain only itself.
312-
CComBSTR outer_html_bstr;
313-
hr = element_in_list->get_outerHTML(&outer_html_bstr);
314-
std::wstring outer_html = outer_html_bstr;
315-
*obscuring_element_description = StringUtilities::ToString(outer_html);
308+
if (are_equal) {
309+
break;
316310
}
317311

318-
319-
VARIANT_BOOL is_child;
320-
hr = this->element_->contains(element_in_list, &is_child);
321-
VARIANT_BOOL is_ancestor;
322-
hr = element_in_list->contains(this->element_, &is_ancestor);
323-
is_obscured = is_obscured ||
324-
(is_child != VARIANT_TRUE && is_ancestor != VARIANT_TRUE);
325-
if (is_obscured || are_equal) {
326-
break;
312+
bool is_list_element_displayed;
313+
Element element_wrapper(element_in_list,
314+
this->containing_window_handle_);
315+
status_code = element_wrapper.IsDisplayed(false,
316+
&is_list_element_displayed);
317+
if (is_list_element_displayed) {
318+
VARIANT_BOOL is_child;
319+
hr = this->element_->contains(element_in_list, &is_child);
320+
VARIANT_BOOL is_ancestor;
321+
hr = element_in_list->contains(this->element_, &is_ancestor);
322+
is_obscured = is_child != VARIANT_TRUE && is_ancestor != VARIANT_TRUE;
323+
if (is_obscured) {
324+
// Return the top-most element in the event we find an obscuring
325+
// element in the tree between this element and the top-most one.
326+
// Note that since it's the top-most element, it will have no
327+
// descendants, so its outerHTML property will contain only itself.
328+
CComBSTR outer_html_bstr;
329+
hr = element_in_list->get_outerHTML(&outer_html_bstr);
330+
std::wstring outer_html = outer_html_bstr;
331+
*obscuring_element_description = StringUtilities::ToString(outer_html);
332+
break;
333+
}
327334
}
328335
}
329336
}

cpp/iedriverserver/CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ available via the project downloads page. Changes in "revision" field indicate
99
private releases checked into the prebuilts directory of the source tree, but
1010
not made generally available on the downloads page.
1111

12+
v3.11.1.3
13+
=========
14+
* Fixed detection of obscured elements when top element is not displayed.
15+
Fixes issue #5668.
16+
1217
v3.11.1.2
1318
=========
1419
* Changed COM variant to JSON serialization in IE. There is an expectation

cpp/iedriverserver/IEDriverServer.rc

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ END
5050
//
5151

5252
VS_VERSION_INFO VERSIONINFO
53-
FILEVERSION 3,11,1,2
54-
PRODUCTVERSION 3,11,1,2
53+
FILEVERSION 3,11,1,3
54+
PRODUCTVERSION 3,11,1,3
5555
FILEFLAGSMASK 0x3fL
5656
#ifdef _DEBUG
5757
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
6868
BEGIN
6969
VALUE "CompanyName", "Software Freedom Conservancy"
7070
VALUE "FileDescription", "Command line server for the IE driver"
71-
VALUE "FileVersion", "3.11.1.2"
71+
VALUE "FileVersion", "3.11.1.3"
7272
VALUE "InternalName", "IEDriverServer.exe"
7373
VALUE "LegalCopyright", "Copyright (C) 2017"
7474
VALUE "OriginalFilename", "IEDriverServer.exe"
7575
VALUE "ProductName", "Selenium WebDriver"
76-
VALUE "ProductVersion", "3.11.1.2"
76+
VALUE "ProductVersion", "3.11.1.3"
7777
END
7878
END
7979
BLOCK "VarFileInfo"
0 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)