Is there a way to use the value in 1 databank as a variable in a subsequent databank's XPATH?
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
-
Option1:
- create one TestSuite variable name temp
- Pass the data source value to that temp
- 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
0 -
:list/partElement[][name ="${temp}"][1]/logicalSerialNumber[1]/text()
"Add double quotes"
0 -
Thank you
0