Hi Jochen,
You're right: the API doesn't support pulling back something other
than an element coming back from the find methods. As Steve points out
in a later email, you can use the JavascriptExecutor to extract the
innerHTML of an element if that's what you need.
The reason for this is to keep the APIs clear, small and unambiguous.
If we allowed "findElement" to return an arbitrary node, we'd need to
change the return type from WebElement (which is clear) to "Node" (or
some variant, which is more ambiguous) In the common case, we do
actually want to return and interact with a WebElement. We're trying
to make the easy stuff easy, and the hard stuff possible (to steal a
phrase :)
Now, there is an argument to be made that we could "re-purpose"
WebElement to act as a Node. In that case, returning a text node would
mean that only "getText" would be a valid method to call. We already
do something a little like this; WebElement has every method you might
want, and it throws an exception if you attempt something illogical.
For example, if you call "toggle" on something other than a checkbox,
an exception will be thrown.
I'm not sure I like that re-purposing. I'm always happy to debate on-list :)
Simon