I need to encode a variable in Jmeter
, but it isn't a parameter. For example:
URL path: /folder/guest/id;token=${token}/profile?details=yes
I want to encode the ${token}
variable, and only the token variable. I know that you can select encode
in the parameters section, but this isn't a parameter.
Does anyone know how to do this?
Referencing a variable in a test element is done by bracketing the variable name with '${' and '}'. Functions are referenced in the same manner, but by convention, the names of functions begin with "__" to avoid conflict with user value names*.
Content encoding This is the character encoding to be used, and is not related to the Content-Encoding HTTP header. So the blank value is normal given you are recording HTTP GET requests.
Per the JMeter user guide __property(): The property function returns the value of a JMeter property. If the property value cannot be found, and no default has been supplied, it returns the property name.
JMeter as of version 2.10 now includes a urlencode function.
${__urlencode(${token})}
See http://jmeter.apache.org/usermanual/functions.html
The best way I found to do this was to use a JavaScript
function:
${__javaScript(encodeURIComponent('${token}'))}
So the request would be:
/folder/guest/id;token= ${__javaScript(encodeURIComponent('${token}'))}/profile?details=yes
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