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

Method HasFirstChildTextNodeOfMultipleChildren

cpp/iedriver/Element.cpp:1730–1805  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1728}
1729
1730bool Element::HasFirstChildTextNodeOfMultipleChildren() {
1731 CComPtr<IHTMLDOMNode> element_node;
1732 HRESULT hr = this->element_.QueryInterface<IHTMLDOMNode>(&element_node);
1733 if (FAILED(hr)) {
1734 LOGHR(WARN, hr) << "QueryInterface for IHTMLDOMNode on element failed.";
1735 return false;
1736 }
1737
1738 CComPtr<IDispatch> child_nodes_dispatch;
1739 hr = element_node->get_childNodes(&child_nodes_dispatch);
1740 if (FAILED(hr)) {
1741 LOGHR(WARN, hr) << "Call to get_childNodes on element failed.";
1742 return false;
1743 }
1744
1745 CComPtr<IHTMLDOMChildrenCollection> child_nodes;
1746 hr = child_nodes_dispatch.QueryInterface<IHTMLDOMChildrenCollection>(&child_nodes);
1747
1748 long length = 0;
1749 hr = child_nodes->get_length(&length);
1750 if (FAILED(hr)) {
1751 LOGHR(WARN, hr) << "Call to get_length on child nodes collection failed.";
1752 return false;
1753 }
1754
1755 // If the element has no children, then it has no single text node child.
1756 // If the element has only one child, then the element itself should be seen
1757 // as the correct size by the caller. Only in the case where we have multiple
1758 // children, and the first is a text element containing non-whitespace text
1759 // should we have to worry about using the text node as the focal point.
1760 if (length > 1) {
1761 CComPtr<IDispatch> child_dispatch;
1762 hr = child_nodes->item(0, &child_dispatch);
1763 if (FAILED(hr)) {
1764 LOGHR(WARN, hr) << "Call to item(0) on child nodes collection failed.";
1765 return false;
1766 }
1767
1768 CComPtr<IHTMLDOMNode> child_node;
1769 hr = child_dispatch.QueryInterface<IHTMLDOMNode>(&child_node);
1770 if (FAILED(hr)) {
1771 LOGHR(WARN, hr) << "QueryInterface for IHTMLDOMNode on child node failed.";
1772 return false;
1773 }
1774
1775 long node_type = 0;
1776 hr = child_node->get_nodeType(&node_type);
1777 if (FAILED(hr)) {
1778 LOGHR(WARN, hr) << "Call to get_nodeType on child node failed.";
1779 return false;
1780 }
1781
1782 if (node_type == 3) {
1783 CComVariant node_value;
1784 hr = child_node->get_nodeValue(&node_value);
1785 if (FAILED(hr)) {
1786 LOGHR(WARN, hr) << "Call to get_nodeValue on child node failed.";
1787 return false;

Callers 1

GetLocationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected