JMeter tests and non-static GET / POST parameters
What is the best strategy to use when writing JMeters tests against a web application where the values of certain query rows and column will change for each run.
Quick, general, example
- You are taken to a web page.
- Enter some information in the form
- Click "Save"
- Behind the scenes, a new record is entered into the database
- You want to edit the entry you entered to go to another web page. Behind the scenes, it passes the page to the parameter with the database id of the newly created string
When you run step 5 of the above test, the page parameter / Database ID will change every time.
In the course of work / strategy, I use
- Record the test using the steps above.
- Pay attention to every place where the query string variable can change from run to run
- Use XPath or Expression Extractor to infer the value from the answer and into the JMeter variable
- Replace all relevant instances of the hardcoded parameter with the above variable.
It works and can be automated to some extent. However, it can become tedious, error prone, and fragile. Is there a better / generally accepted way to handle this situation? (Or is this why most people just use JMeter to play logs? (-;)
source to share
Sounds like yours to me on the right track. The best JMeter can achieve is to extract page variables with regex or xpath message handler. However, you are absolutely correct that this is not a scalable solution and is becoming more and more difficult to maintain or grow.
If you have reached a point then you may need to consider a tool that is more specialized for this kind of problem. Have a look at a web testing tool like Watir, it will automatically handle the mail parameter parameters; but you still have to fetch parameters if you need to do a database update, but using Watir allows better code reuse, making the problem less painful.
source to share