replace a dynamic value to a XML attribute in Jmeter

1,530 views
Skip to first unread message

swarupa....@gmail.com

unread,
Dec 8, 2016, 5:59:41 PM12/8/16
to jmeter-plugins

Hi All,

 

I am very new to Jmeter am facing an issues, I have a requirement as mentioned below. I need your inputs/suggestions.

 

I need to send a XML input in an HTTP Request Sampler

I need to pass the xml content to a http Parameter.

In XML file there is a placeholder of extension in hml id tag and I need to pass this values dynamically whether I have to generate it dynamically.


What I did:

 

I have created a Http Request sampler and BSF PreProcessor

Passed the XML to a parameter using (${__FileToString(${filepath},utf-8,No)}


Using below script 



Sample File 


I am not seeing any errors in Jmeter. But it's failing to generate unique extension. Please help me on this.Thanks,
Swarupa




gli...@gmail.com

unread,
Dec 14, 2016, 1:38:34 AM12/14/16
to jmeter-plugins, swarupa....@gmail.com
I would recommend the following:


<hmlid extension="${__RandomString(8,abcdefghijklmnopqrstuvwxyz,)}" root="6.840.1.113999.3.1472"/>
  • Use __FileToString() function combined with __eval() function right in the HTTP Request like:
${__eval(${__FileToString(${filepath},UTF-8,)})}


This way you will get random "extension" attribute each time the function will be called and won't have to use scripting for that. See Here’s What to Do to Combine Multiple JMeter Variables for more details on the domain. 
 



Reply all
Reply to author
Forward
0 new messages