-1

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...

H.B.
  • 166,899
  • 29
  • 327
  • 400

1 Answers1

1

Probably, you can call a JavaScript function/line which could return you html of body tag, if that is the only think that you require.

Also, javascript might have some function to return the complete page source.

iMatoria
  • 1,450
  • 2
  • 19
  • 35
  • But how would i call JS with an `IWebDriver`? – H.B. Aug 03 '12 at 23:32
  • http://stackoverflow.com/questions/6229769/execute-javascript-using-selenium-webdriver-in-c-sharp – iMatoria Aug 04 '12 at 10:07
  • Thanks for that link, i'll need to test that some time, though the body tag is not enough, i need the entire page, which from looking around seems to be difficult with JS too. – H.B. Aug 04 '12 at 14:04