Lokesh Mahajan
Lokesh Mahajan

Reputation: 11

How to deal with dynamic parameter name in JMeter

Login page is having dynamic password field name: every time user visits the login page field name looks like PASSWORD_673834937, and on next visit, it looks like PASSWORD_673857943.

I have created many scripts which were working as of today, but in latest build they bring in this change to the password field... before this it was always PASSWORD only. So all my scripts were failing. What is the workaround, so that all my scripts start working with dynamic field name?

OLD JMETER SCRIPT using name as "PASSWORD"

NEW changes to the password field

Upvotes: 0

Views: 2428

Answers (2)

Dmitri T
Dmitri T

Reputation: 168217

This is a matter of missing correlation, you would need this sooner or later given you continue playing with JMeter.

The idea of bypassing dynamic parameters is building your Test Plan as follows:

  • Request 1 (open login page)
    • Extract dynamic parameters and store them into JMeter Variables
  • Request 2 (perform login) providing credentials and all dynamic variables from the previous step

    1. Add CSS/JQuery Extractor (be aware that it is not recommended to use regular expressions to work with HTML data) as a child of the register.asp page and configure it as follows:

      • Reference Name: anything meaningful, i.e. name
      • CSS/JQuery Expression: input[title=Password]
      • Attribute: name
    2. Replace PASSWORD_673834937 with ${name} in the new script.

Upvotes: 0

timbre timbre
timbre timbre

Reputation: 14004

  1. Under register.asp sampler, add RegEx Post-Processor
  2. Specify the following parameters:

    enter image description here

(i.e. the regular expression is <input TYPE="password" NAME="([^"]+)")

  1. In HTTP Request, in the row where password is provided, specify variable created by RegEx Post-Processor in Field name, instead of static name. For example, since the variable I created above is called PasswordFieldName, the HTTP Sampler should look like this (omitting irrelevant parameters):

    enter image description here

Upvotes: 1

Related Questions