Hi,
If you look at XPath specification the contains function is defined the following way (
http://www.w3.org/TR/xpath/#function-contains):
Function: boolean contains(string, string)
The contains function returns true if the first argument string contains the second argument string, and otherwise returns false.
In your specific case the first argument of the contains function is the context node (the dot). So the XPath engine has to convert it to a string before it can run the contains function.
The conversion is done implicitly using the
string function which for a node returns its string value (as defined here
http://www.w3.org/TR/xpath/#function-string).
In your case the nodes are elements (divs) so so there string value is the following (
http://www.w3.org/TR/xpath/#element-nodes):
The string-value of an element node is the concatenation of the string-values of all text node descendants of the element node in document order.
As an example, to see what the string value looks like you can evaluate the following XPath in the same page the screenshot was taken:
string(.//div[@id='div_loginContainer'])
As you can see the resulting string does contain 'You can change your password'
So the result you are getting is expected.
Now I think the XPath expression you are looking for here is:
//div[contains(text(),'You can change your password')]
This matches the divs that have a child text node which contains 'You can change your password'
Hope this helps,
Regards,
Pierre