So there is IWebDriver.PageSource
but this does not return the actual source but a bastardisation which has some characters escaped:
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.
I tried to work around this by using IWebElement.GetAttribute("innerHTML")
but that also is not the actual HTML code, in this case all the self closing tags (where in normal HTML the closing tag can be omitted) were turned into opening tags, e.g. <link ... />
is then <link ... >
which has the not so nice side-effect of making a previously valid XHTML document invalid.
Still i am hoping for a somewhat simple solution but right now it seems impossible with the IWebDriver
alone due to the bad interface/framework design...