Is there any way to get a page source along with IE comments via WatiN? WatiN exposes DocumentElement.outerHTML but it contains a document without the comments.
EDIT When we have a look at IE comments via View Source in IE, we see something like:
<!--[if IE]>
<p>Welcome to Internet Explorer.</p>
<![endif]-->
But when we have a look at the actually rendered HTML via the document object, we see only:
<p>Welcome to Internet Explorer.</p>
I.e. the IE comments are not included into the rendered document, but the usual HTML comments are.
Add this to top of your code:
and use this to get the actual HTML content
Good luck.
Edit:
It seems I misunderstood what you want. After you edit your post, I tried something. Opened a website in Opera and Chrome which include
<!--[if IE]-->, then ran this command in the console:document.head.innerHTML. Both browsers gave output with the[if IE], however when trying it in IE it seems after the page is rendered IE removes all of these.There must be some way to achieve this but I couldn’t find a solution without downloading the whole page with
System.Netor something else then reading its content.Edit 2:
I found another way, but not sure if you like the solution. Look at this code: http://pastebin.com/4EvLSuEL
It makes an ajax call to load the page content, then pastes the result into a hidden
textarea. After that, by using WatiN’sElementWithTagwe get thattextareavalue into our stringmyContent.Hope it helps you, this is what I can do best.