Forum Discussion

rwestbury's avatar
rwestbury
Contributor
14 years ago

How to download the HTML source code into a String?

Hi,



This is for anyone who is having problems using the WebTesting WebCompare feature. The challenge I'm having is that there's a random session ID stored in the HTML source code that is different every time I go to the web page. That causes WebCompare to fail due to that random session ID.



Is there a workaround for this? Can I wildcard out the session ID? I tried to no avail. If it's possible please show an example.



Is there a way I can download the HTML source code into a String in TestComplete? What would the code be to do that?



Thanks,



Robert.

3 Replies

  • Has anyone had success masking out a random session ID that's stored in the source HTML code and comparing the HTML code to a baseline version? I know this is possible. However in order to do it in code, I need to be able to grab the HTML source code for the website and store that in a string. How do I do that?



    Thanks,



    Robert
  • In JScript (using Internet Explorer example and assuming the appropriate object tree model):



    var page = Sys.Process("iexplore").Page("www.google.com");

    var pageText = page.Application.document.documentElement.innerHTML;





    As far as masking your session ID it should be as simple as a regex replace:



    var pageText = pageText.replace(sessionIDPattern,"");