> Hi, I have a page with an XHTML doctype.
>
> When I do getPageSource(), I get the page source as a string, but
> without the doctype prolog. Is that expected behavior? When I look
> at the DOM in Firebug, I see the doctype there.
You should not trust the consistency of getPageSource(), especially
for cross-browser purposes.
Let me quote the WebDriver API:
Get the source of the last loaded page. If the page has been
modified after loading (for example, by Javascript) there is
no guarantee that the returned text is that of the modified
page. Please consult the documentation of the particular driver
being used to determine whether the returned text reflects the
current state of the page or the text last sent by the web
server. The page source returned is a representation of the
underlying DOM: do not expect it to be formatted or escaped in
the same way as the response sent from the web server. Think of
it as an artist's impression.
Some browsers may return the modified DOM, some may return the document
as it were when it was loaded. The text wrapping and indentation is
almost certainly going to be different, and it goes without saying that
the same thing applies for the doctype.
> Is there some other way of detecting the doctype using webdriver?
WebDriver is not designed for this purpose. I recommend using another
library, such as curl or a proxy, for determining the doctype of a
particular document.
--Jim