Able to locate all div elements in UI page using this XPATH locator : //div[contains(.,'')]
irrespective of the text inside them. What does .,''
mean ?
Consider below example:
XPath to specifically select div
with text - 'Apple'
would be //div[contains(.,'Apple')]
.
What is its CSS equivalent ?
<div>
<span> Apple </span>
</div>
CodePudding user response:
//div[contains(.,'Apple')]
//div
means to select alldiv
elements in the document.//div[
predicate]
means to filter those per the given predicate.contains(
str,
substr)
means to return true iff str contains the substring, substr..
is the context node. (See Current node vs. Context node in XSLT/XPath?) Within the predicate of your XPath, it will be adiv
element. When passed as a function parameter with type string, it will be converted to the string value of the node.- The string-value of an element is equal to the concatenation of the string values of its children elements.
Therefore, your XPath returns all div
elements in the document whose string value contains the 'Apple'
substring.
There is no CSS equivalent.