Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Want to store data in variable fetching from XML databank in javascript for custom assertion

Anushree
Anushree Posts: 1

Want to store data in variable fetching from XML databank in javascript for custom assertion. Can you please help me?
For example, In XML data bank I have extracted an element named "Date"
In Custom script, I want to store this element in a variable. What should be the syntax?

Answers

  • OmarR
    OmarR Posts: 231 admin

    Good morning,

    You can access your databank variables using a special data source name: "Generated Data Source". For example:
    var = context.getValue("Generated Data Source", "columnName")

    The "columnName" here would be the column name in the XML Data Bank.

    Similarly, to access values from a table or an excel data source, you could simply use the name given to the data source. For example:
    var = context.getValue("myTable", "columnName")
    The "columnName" here would be the column name in the Table-datasource called "myTable".

    See AccessingDataSourcesfromScripts for more info.