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

BrianQuantumBrianQuantum Posts: 20

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


  • ParasofttoudayaParasofttoudaya Posts: 166


    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()**

    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

  • ParasofttoudayaParasofttoudaya Posts: 166

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

    "Add double quotes"

  • BrianQuantumBrianQuantum Posts: 20

    Thank you

Sign In or Register to comment.