简体   繁体   中英

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!

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM