Forum Discussion

rafal_wojciecho's avatar
rafal_wojciecho
New Contributor
12 years ago

Updating XMLCheckpoints at runtime.

In one of our projects we have hundreds of XMLCheckpoints, when performing tests on different environments some of values in those XMLs will differ. 



We tried modifying them with external application. But when it is done at runtime there is no way to reload them other then clicking "Yes" when a popup with warning that file has been modified by external application, and you can never tell when will it "popup".



We tried it also with something like this:




var checkpoint = XML["checkpoint name"]


var node = document["selectNodes"]("//node_to_change")


node["Item"](0).text = "test2";


document["Save"](xml_path);



but the same problem occures.


 



So the question is: How to reload XMLCheckpoints at runtime? Or is there a way to restart TestComplete from script without restarting whole machine?



Best regards

4 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Rafal,


     


    You may reload the stored XML Checkpoint in the following way:


    //JScript


     // Load data from MyFile1.xml to MyXMLCheckpoint


     XML.MyXMLCheckpoint.Document.load("C:\MyFolder1\MyFile1.xml");


     //Compare the loaded data against MyFile2.xml


     XML.MyXMLCheckpoint.Check("C:\MyFolder2\MyFile2.xml");


     


    You can use another way - modify the xml content in the XML Checkpoint before comparing. Here is an example:


    //JScript


      var xmlData = Sys.OleObject("Msxml2.DOMDocument.4.0");


      xmlData.async = false;


      xmlData = XML.MyXMLCheckpoint.Document;


      var nodes = xmlData.selectNodes("//node_to_change");


      for(var i = 0; i < nodes.length; i++)


      { 


        nodes.item(i).childNodes.item(0).data = "<new data>";


      }

  • Hi. Thanks for your reply.



    I was aware of this functionality. But there is one problem If you need to "enable the Update XML data option in the Stores Options dialog" to use it. I need to do it at runtime, I mean from the script. Is there anyway to do it?

  • Great, XML.MyXMLCheckpoint.Document.load("C:\MyFolder1\MyFile1.xml") is what I was looking for.



    Thanks for your help!