Skip to content

Commit

Permalink
Fixing IE detection of obscured elements when top element is not disp…
Browse files Browse the repository at this point in the history
…layed

Fixes issue SeleniumHQ#5668.
  • Loading branch information
jimevans committed Mar 23, 2018
1 parent 61d741b commit f13f3f5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
43 changes: 25 additions & 18 deletions cpp/iedriver/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ bool Element::IsObscured(LocationInfo* click_location,
return false;
}

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


VARIANT_BOOL is_child;
hr = this->element_->contains(element_in_list, &is_child);
VARIANT_BOOL is_ancestor;
hr = element_in_list->contains(this->element_, &is_ancestor);
is_obscured = is_obscured ||
(is_child != VARIANT_TRUE && is_ancestor != VARIANT_TRUE);
if (is_obscured || are_equal) {
break;
bool is_list_element_displayed;
Element element_wrapper(element_in_list,
this->containing_window_handle_);
status_code = element_wrapper.IsDisplayed(false,
&is_list_element_displayed);
if (is_list_element_displayed) {
VARIANT_BOOL is_child;
hr = this->element_->contains(element_in_list, &is_child);
VARIANT_BOOL is_ancestor;
hr = element_in_list->contains(this->element_, &is_ancestor);
is_obscured = is_child != VARIANT_TRUE && is_ancestor != VARIANT_TRUE;
if (is_obscured) {
// Return the top-most element in the event we find an obscuring
// element in the tree between this element and the top-most one.
// Note that since it's the top-most element, it will have no
// descendants, so its outerHTML property will contain only itself.
CComBSTR outer_html_bstr;
hr = element_in_list->get_outerHTML(&outer_html_bstr);
std::wstring outer_html = outer_html_bstr;
*obscuring_element_description = StringUtilities::ToString(outer_html);
break;
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions cpp/iedriverserver/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ available via the project downloads page. Changes in "revision" field indicate
private releases checked into the prebuilts directory of the source tree, but
not made generally available on the downloads page.

v3.11.1.3
=========
* Fixed detection of obscured elements when top element is not displayed.
Fixes issue #5668.

v3.11.1.2
=========
* Changed COM variant to JSON serialization in IE. There is an expectation
Expand Down
8 changes: 4 additions & 4 deletions cpp/iedriverserver/IEDriverServer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,11,1,2
PRODUCTVERSION 3,11,1,2
FILEVERSION 3,11,1,3
PRODUCTVERSION 3,11,1,3
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,12 +68,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Software Freedom Conservancy"
VALUE "FileDescription", "Command line server for the IE driver"
VALUE "FileVersion", "3.11.1.2"
VALUE "FileVersion", "3.11.1.3"
VALUE "InternalName", "IEDriverServer.exe"
VALUE "LegalCopyright", "Copyright (C) 2017"
VALUE "OriginalFilename", "IEDriverServer.exe"
VALUE "ProductName", "Selenium WebDriver"
VALUE "ProductVersion", "3.11.1.2"
VALUE "ProductVersion", "3.11.1.3"
END
END
BLOCK "VarFileInfo"
Expand Down
Binary file modified cpp/prebuilt/Win32/Release/IEDriverServer.exe
Binary file not shown.
Binary file modified cpp/prebuilt/x64/Release/IEDriverServer.exe
Binary file not shown.

0 comments on commit f13f3f5

Please sign in to comment.