cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the HTML for the current page

SOLVED
Highlighted
Occasional Contributor

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 me the entire document.

 

I want to include the HTML of my page in the body of a REST API call to a service that validates the HTML.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Contributor

Re: How to get the HTML for the current page

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;

View solution in original post

1 REPLY 1
Highlighted
Occasional Contributor

Re: How to get the HTML for the current page

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;

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors