Submit and vote on feature ideas.

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.

Python or Jython script to change a value in XML file and update to a new value and use as data

Chinnu
Chinnu Posts: 18

My scenario:
I want to execute a query and get XML , store in output file, picked up in python and changing few values inside XML and again using it as data for subsequent story

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    store in output file

    You typically use the Write File tool to write files. However, it is typical to store XML nodes in memory using an XML Data Bank. Subsequent tests can reference the node or nodes that you select in the XML Data Bank using a "custom column name" you also configure.

    picked up in python and changing few values inside XML

    Have you considered using the "Allow Alteration" option in the XML Data Bank or XML Transformer tool? This will allow you to modify text nodes in the document. You can change the value and can reference variables in the replacement value if needed. You can also setup an extraction on the root node if you need to extract the entire document with the alteration.

  • Chinnu
    Chinnu Posts: 18

    ok thank you, How can i send customized python script for asserting date range calculations and time stamp?

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited September 2021

    How can i send customized python script for asserting date range calculations and time stamp?

    Use the XML Assertor. There are various built-in assertions available, including ones for Data/Time Range/Difference. If you need to script something custom then you can add the "Custom" assertion which allows you to provide a script.

  • Chinnu
    Chinnu Posts: 18

    Thank you