Skip to content

How to store data to a Xml file in Files module from within a test run



In this example you will see how to store a Xml string to a file in Files module.

For saving data to a file in Xml format, first you need to build a dataset (data in the form of rows & columns stored in memory) and populate the dataset as this forms input for the file. Steps to follow (the same are shown in the test script snippet)

  • Create dataset (instruction #1)
  • Initialize by adding a Row (instruction #2)
  • Populate values to the Row (instructions #3 thru #8)
  • Save dataset to a file in the format of a Xml (instruction #11)

# Command Target Value
Creating the dataset and specifying the data definition name of the data file
1 ddCreateDataSet dsBookDetails BookXml||ISBN_10,searchKeywordForProduct,productTitle,author,publisher,edition
Initializing dataset by adding a row
2 ddAddRows dsBookDetails 1
Setting values for the first row in the dataset
3 ddSetCellValueByName dsBookDetails(0,ISBN_10) 1951028023
4 ddSetCellValueByName dsBookDetails(0,searchKeywordForProduct) I AM A LEADER
5 ddSetCellValueByName dsBookDetails(0,productTitle) I AM A LEADER: A 90-Day Leadership Journal for Kids (Ages 8 - 12)
6 ddSetCellValueByName dsBookDetails(0,author) Peter J. Liang
7 ddSetCellValueByName dsBookDetails(0,publisher) Absolute Author Publishing House (July 19, 2019)
8 ddSetCellValueByName dsBookDetails(0,edition) kindle
Print the number of rows
9 ddGetRowCount dsBookDetails count
10 echo ${count}
Save dataset to a Xml file
11 ddPersistDataSetToXmlFile dsBookDetails BookDetails.Xml

Tips, Tricks, Gotchas & Best Practices: 

In this example, 

  • Dataset is created using Dynamic Data Definition (not defined in Data Definitions module) and then populating using ddSetCellValueByName. This is one of the many ways of creating and populating dataset in Worksoft SaaS platform. You may want to read more about datasets and populating datasets by referring to the article here.


Feedback and Knowledge Base