(This article is part of the JMeter Series)
While testing a Rails application there was a situation where a background worker (DJB or background task) would get an order to execute and eventually the completed order would appear on a page.
Thus we needed to wait for the page to be updated and continue the test after.
User Defined Variables
I'm predefining used variables here - see “We set up our variables” in the Extracting text from a page and using it somewhere else in JMeter article for an exaplanation why.
Clear Loop Variable
This step is not strictly necessary in our example here, however if you want to reuse this sequence of steps more than one time - that is call it from different places, then you need to clear the loop variable first.
Since creating these steps was not easy, I've put a debug statement in so that I see, when JMeter calls into these steps and to see how the variables are set.
The While Controler
Here we really start the loop.
Getting the page
We get the page we want to check.
Extract the data we want to check from the page and assign it to our loop variable
Make sure our request is not being cached
It's better - as far as we can - to be sure we force the web application to recreate the page we're waiting for to change. I'm not sure I've done it right here, however it works:
Wait a bit before re-looping
We wait two seconds here before retrying.
You can download this JMeter test from here
Tomáš Pospíšek, 4.1.2011