I am trying to create JMeter tests and use the same tests for different environments- QA, Staging, Dev etc. I want to dynamically change the IP address by either changing the CSV File or passing the value through ant script or manually through command prompt. Unfortunately, I haven't been able to do so. The Test doesn't pick up the value from CSV file or from the command prompt.
Can someone please help me.
Thanks in Advance.
I usually add a HTTP Request Defaults element to the test and change it manually.
Otherwise for automation, you can modify the jmx file using a script.
Edit in fact, you can use ant filters to change this dynamically at build time. For example, use a filter of <filter token="SERVER" value="${server}"/>
and a copy
target with filtering on the file below will get you a new jmx file which will use the correct server.
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP Request Defaults" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">@SERVER@</stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
</ConfigTestElement>
First of all, you should place your csv file where you saved your test script file. Normally test script can be saved as with jmx extension and placed your csv file in the same directory of it.
Content of the CSV file as follows:
url;www.test123.com
url;www.test1234.com
url;www.test12345.com
Note that in the Thread Group configuration, thread count must be minimum number of lines in the csv file. According to above CSV file, we should define minimum 3 thread in the Thread Group.
After this configuration, JMeter will automatically call Http Request Defaults configuration everytime when a thread is executed.
CSV Data Set Config
HTTP Request Defaults
HTTP Request (Only Path is set)
Regular Expression Extractor (Optional to find specific response)
Write found regex result to a file (Optional)
Source: http://www.codesenior.com/en/tutorial/JMeter-Dynamically-Change-Server-Name-Using-CSV-Data-File
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With