MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / GetContainingDocument

Method GetContainingDocument

cpp/iedriver/Element.cpp:1582–1622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1580}
1581
1582int Element::GetContainingDocument(const bool use_dom_node,
1583 IHTMLDocument2** doc) {
1584 LOG(TRACE) << "Entering Element::GetContainingDocument";
1585
1586 HRESULT hr = S_OK;
1587 CComPtr<IDispatch> dispatch_doc;
1588
1589 if (use_dom_node) {
1590 CComPtr<IHTMLDOMNode2> node;
1591 hr = this->element_->QueryInterface(&node);
1592 if (FAILED(hr)) {
1593 LOGHR(WARN, hr) << "Unable to cast element to IHTMLDomNode2";
1594 return ENOSUCHDOCUMENT;
1595 }
1596
1597 hr = node->get_ownerDocument(&dispatch_doc);
1598 if (FAILED(hr)) {
1599 LOGHR(WARN, hr) << "Unable to locate owning document, call to IHTMLDOMNode2::get_ownerDocument failed";
1600 return ENOSUCHDOCUMENT;
1601 }
1602 } else {
1603 hr = this->element_->get_document(&dispatch_doc);
1604 if (FAILED(hr)) {
1605 LOGHR(WARN, hr) << "Unable to locate document property, call to IHTMLELement::get_document failed";
1606 return ENOSUCHDOCUMENT;
1607 }
1608 }
1609
1610 try {
1611 hr = dispatch_doc.QueryInterface<IHTMLDocument2>(doc);
1612 if (FAILED(hr)) {
1613 LOGHR(WARN, hr) << "Found document but it's not the expected type (IHTMLDocument2)";
1614 return ENOSUCHDOCUMENT;
1615 }
1616 } catch(...) {
1617 LOG(WARN) << "Found document but it's not the expected type (IHTMLDocument2)";
1618 return ENOSUCHDOCUMENT;
1619 }
1620
1621 return WD_SUCCESS;
1622}
1623
1624int Element::GetDocumentFromWindow(IHTMLWindow2* parent_window,
1625 IHTMLDocument2** parent_doc) {

Callers 15

IsDisplayedMethod · 0.95
IsEnabledMethod · 0.95
IsInteractableMethod · 0.95
IsFocusableMethod · 0.95
IsObscuredMethod · 0.95
HasShadowRootMethod · 0.95
GetComputedStyleMethod · 0.95
IsEditableMethod · 0.95
GetAttributeValueMethod · 0.95
GetCssPropertyValueMethod · 0.95
IsHiddenByOverflowMethod · 0.95

Calls 1

LOGClass · 0.50

Tested by

no test coverage detected