Forum Discussion

RobertDAltman's avatar
RobertDAltman
Occasional Contributor
7 years ago

How to get the HTML for the current page

In JScript, how do I retrieve the entire HTML (as a text string) of the current page?  I assume it's some property or method off of page.contentDocument, but I can't find anything that seems to give ...
  • RobertDAltman's avatar
    7 years ago

    Ha! Figured it out.  Thanks to this SO post, an answer that works in TestComplete is:

     

    var page = Sys.Browser().Page("*");
    var html = '<!DOCTYPE HTML>' + page.contentDocument.documentElement.outerHTML;