I'm using JMeter for regression tests on Webservice. I'm trying to use an Xpath assertion using a CSV file to avoid creating several XPath assertions.
Here's an overview of my CSV file test.csv (it defines an expected value for each field) :
field1,value1
field2,value2
field3,value3
And here's my Xpath assertion :
//Envelope/Body/response/result/data/types/${field)}[text()='${value)}']
Where field
& value
are my variables names in my CSV Data Set Config.
When I run my test with 1 iteration, it checks the response with the first line of my CSV. I have to put at least 3 iterations on my thread group to make sure each line of my CSV is used.
I've tried CSVRead function with this kind of Xpath assertion :
//Envelope/Body/response/result/donnee/types/${__CSVRead(test.csv,0)}[text()='${__CSVRead(test.csv,1)}']
But I don't know how to loop on it. I don't know if it's possible.
I would recommend building your project as follows:
Loop Controller (with number of loops matching number of lines in your CSV file
Beanshell Sampler (put below code to "Script" area)
return ctx.getPreviousResult().getResponseDataAsString();
Beanshell Sampler will just fetch response data from the parent HTTP Request or SOAP Request without re-executing the request so you will be able to re-use response data as many times as required.
For more information on Beanshell scripting in Apache JMeter refer to How to use BeanShell: JMeter's favorite built-in component guide.
If you have any problems check out XPathNameSpaceAssertionDemo project
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句