0
votes

I have a problem and I can't find any solution... I am actually developing a test for a Web Service (let's call it WS).

To test it, I have an HTTP Request, with in the body data as XML. The problem is that in this XML, I would like some attributes to be variable (or parameters I could change).

For example, here is the XML file :

    <measure>
        <time>2020-04-07T10:45:00</time>
        <value index="0">
            <value>
                <basicData xsi:type="DATA1">
                    <data1 data1number="10">
                        <numberd1>13</numberd1>
                    </data1>
                </basicData>
            </value>
        </value>
        <value index="0">
            <measuredValue>
                <basicData xsi:type="DATA2">
                    <data2 data2number="8">
                        <numberd2>22</numberd2>
                    </data2>
                </basicData>
            </value>
        </value>
    </measure>

I would like to get random values or variables values for the numberd1 and numberd2. Is it possible to modify some attributes in the XML body data of an HTTP Request in JMETER?

The XML in the body data would be a template, which would change with the different parameters (number d1n number d2) that would change.

Thank you for any anwser.

2

2 Answers

0
votes

1/ Just replace the content between the opening and closing time tags like this :

  <time>${__time(yyyy-MM-dd'T'hh:mm:ss)}</time>

2/ add a Flow Control Action with a duration equals to 120000 (2min) in child of your thread group :

enter image description here

0
votes

Sure you can, for random numeric values you can substitute hard-coded numbers with __Random() function like:

<numberd1>${__Random(0,100,)}</numberd1>

and

<numberd2>${__Random(0,100,)}</numberd2>

this way you will have a random number from 0 to 99 inclusively each time the function is called

enter image description here


If you want the tests to be repeatable another option is to pre-generate numberd1 and numberd2 pairs, store them into a CSV file and use CSV Data Set Config for feeding the request with the values from the CSV file.