Given the following HTML page:
<html> <head> <title>WatiN Test</title> </head> <body> <div> <p>Hello World!</p> </div> </body> </html>
I would like to be able to search for some text (for example, "World" ) and get a link to its parent element (in this case, the <p> element).
If I try this:
var element = ie.Element(Find.ByText(t => t.Contains("World")))
or that:
var element = ie.Element(e => e.Text != null && e.Text.Contains("World"));
I am returning an <html> element. This is consistent with the WatiN documentation for Element.Text , which states: "Gets the inner text of this element (and the inner text of all elements contained in this element)."
Since all the text inside the page is contained in the <html> element, I always get this back instead of the immediate parent.
Is there a way to get the text immediately below the element (and not the text inside the elements contained in it)?
Is there any other way to do this?
Many thanks.
c # watin
James morcom
source share