user123pw" /> user123pw" /> user123pw"/>

How to parameterize username and password in jmeter?

34 views Asked by At

How to remove hardcoding in the below code?

<stringProp name="Authorization.username">user123</stringProp><stringProp name="Authorization.password">pwd123</stringProp>
2

There are 2 answers

2
Ivan G On BEST ANSWER

You can use __P() function to read the credentials from JMeter properties.

enter image description here

When you run JMeter test in command-line non-GUI mode you will be able to pass the credentials via -J command-line arguments like:

jmeter -Jusername=user123 -Jpassword=pwd123 -t test.jmx .....

More information:

1
Diego1974 On

It seems a job for User Defined Variables. As you can see here: https://jmeter.apache.org/usermanual/functions.html

at par 20.3

Referencing a variable in a test element is done by bracketing the variable name with '${' and '}'.

So basically something like ${jmxUsr} and ${jmxPwd} in your test script.
Values can be assigned in "Test Plan" or "Thread Group" (right click till "User Defined Variables" )