Using Axe Harness To Create XM…
  • RSS Feed

Last modified on 8/29/2014 11:31 AM by User.


Using Axe Harness To Create XML Documents with Repeated Similar Nodes

Axe Harness can be used to create XML structures for Automated Testing purposes based on template XML files. It is sometimes required to create Documents with repeated node structures e.g.  


Here the <User> node is required three times with the same structure with varying data. This can be easily created using Axe Harness allowing re-use of the common structures.  The HarnessDemo project can be extended to demonstrate this capability as follows:

Firstly we need to create the outline template XML as below:


Saved as “UserDetails2” in the data folder of the HarnessDemo project.

The token  %User% has been set up here to take the first User Node. We will also need to create the XML “Fragment” which contains the User structure in parameterised format as below:


This is saved as “UserFragment.xml” in the data folder in the HarnessDemo project.

Note the additional %User% token outside of the required fragment, this is so that when Axe adds this to the “UserDetails2” XML structure, replacing the original %User% token it will still maintain a %User% token, this time below the <User> node e.g. 


We can Save the file and use it as input for a second pass, repeating the process until we choose to replace the final token with a Blank value to recreate our fully formed XML file.


 So how is this achieved in the Axe Object maps and Subtest layouts? Firstly we need to declare the %User% token location in the Object Map, this is done as follows:

Here we have extended the HarnessDemo object map “DemoXML.ObjectMap.xml” to contain the entry for the new node “User”, with the simple xpath to locate the token:


We can then use the following subtest structure to load the template, load the fragment for the first node and set the values in the fragment:


Calling this subtest on its own will create the following structure in myfile.xml:

We can then add further rows to add 2 new nodes and a final blank entry:


Called from a test table as follows:


This will result in the following file structure being created: