Search code examples
xmljmeterhttprequestperformance-testing

Jmeter - How to parameterize XML request body using a file in Jmeter?


I have a XML request as follows:

<Request>
    <Header><Log><Level>None</Level></Log></Header>
    <Body>
        <Action>
            <GetService>
                <Code>ABC</Code>
                <CodeValue>XYZ</CodeValue>
            </GetService>
        </Action>
    </Body> </Request>

I would like to have a file which has data for two columns - Code and CodeValue. For example,

Code|CodeValue
--------------
ABC|XYZ
DEF|MNO

How should I parameterize my XML request body so that Jmeter can dynamically use data from the file as the XML values? How should I structure my file?

Thanks in advance!


Solution

  • You can use csv file in JMeter to parameterize the test data.

    • To get an idea, Go to this site . Scorll down to the section - CSV Data Set Config
    • Keep your data in a csv file as shown in the site. add CSV Data Set Config in your test plan. Update the file path.
    • Update your XML as given below.
    <Request>
            <Header><Log><Level>None</Level></Log></Header>
            <Body>
                <Action>
                    <GetService>
                        <Code>${Code}</Code>
                        <CodeValue>${CodeValue}</CodeValue>
                    </GetService>
                </Action>
            </Body> </Request>