On Thu, Feb 21, 2013 at 07:47:55AM -0800, Alexei Barantsev wrote:
> Currently, we can't use Selenium to deal with "true" XHTML pages that
> have application/xhtml+xml content type. The root cause is inability
> to resolve XML namespaces (unless they all are specified in the
> top-level html element that is usually not the case).
So basically we must provide a custom namespace resolver to
document.evaluate(…), similar to the one we have for SVG currently.
> To allow this ability we need to add a new command to the API (and the
> protocol) to add a namespace resolver, like
>
> driver.manage().namespaces().add("xhtml", "
http://www.w3.org/1999/xhtml");
If we can avoid it, my preference would be to do this transparently by
either providing a static list of known XML namespaces (extending our
current list to also include a few more), or to parse the DOM to find
out what namespaces are used and include all of them in the XPath
evaulation call.
The latter option of autodetecting used namespaces may have performance
implications depending on how and where we check, and on the size and
complexity of the DOM.
Secondly, we'd need an algorithm for parsing DOM nodes with the xmlns
attribute since the namespace key from the attribute's value (typically
the last part of the path in the URL) can be overridden like this:
xmlns:CUSTOMNS="
http://example.org/foons"
The autodetection of namespaces could either be done on document load or
on the first (or potentially all) calls to find_element[s]_by_xpath().
Due to the asyncedness of most documents these days, always checking
would be the safest, but might also have the biggest performance
implication.
If none of this is feasible, I'd consider supporting Alexei's proposal
for a new API call.