Looking for an element having an indicator that is in its child element?

Looking for an element having an indicator that is in its child element?

To select a div element that contains multiple descendant text nodes with specific text values, including nested div elements, you can use the descendant:: axis to select all descendant elements, regardless of their depth in the hierarchy, and the text() function to select the text nodes that match your criteria.

Here's an example XPath expression that selects the div element that contains the text nodes "happy" and "bday", including nested div elements:

//div[descendant::text()[contains(., "happy")] and descendant::text()[contains(., "bday")]]

This expression selects all div elements (//div) that have a descendant text() node containing the string "happy" (descendant::text()[contains(., "happy")]) and also have a descendant text() node containing the string "bday" (descendant::text()[contains(., "bday")]).

Note that this expression assumes that the span elements containing the text nodes "happy" and "bday" are descendants of the div element, regardless of their depth in the hierarchy. If they are not, you may need to adjust the expression to use additional axes or predicates to navigate to the correct elements.