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.

Is there a way to use the value in 1 databank as a variable in a subsequent databank's XPATH?

BrianQuantum
BrianQuantum Posts: 23

I have a GET REST call that gets data and I store that data in an XML databank, for example, a part name (partName). In the next GET REST request, I want to search the data returned and store only that data that is associated with the partName. If I knew what the part name would be, I could code the XPATH to be something like: /:list/partElement[][name ="widget"][1]/logicalSerialNumber[1]/text(). But since I don't know what the name will be in advance, I need something like /:list/partElement[][name =partNameFromDatabank}][1]/logicalSerialNumber[1]/text(), where "partNameFromDatabank" is what it says, the part name from the earlier databank. Any thoughts? Thanks

Comments

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    Option1:

    1. create one TestSuite variable name temp
    2. Pass the data source value to that temp
    3. And try to use the temp value in the xpath expression
      ** :list/partElement[][name =${temp}][1]/logicalSerialNumber[1]/text()**

    Option2:
    Construct the whole xpath using extension tool like this
    var temp = ":list/partElement[][name = " + context.getValue("generatedDataSource","variableName") +"][1]/logicalSerialNumber[1]/text()" ;

    Assign the temp to any variable

    In xpath expression you can use it as parameterized value.

    Note: For some reason Append is not working, otherwise it would be easiest option

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    :list/partElement[][name ="${temp}"][1]/logicalSerialNumber[1]/text()

    "Add double quotes"

  • BrianQuantum
    BrianQuantum Posts: 23

    Thank you