...
The main challenge when creating a JMeter script for a Wicket application is that the links are dynamic. Of course, this is a very good thing from a security point of view. It is possible to record a test using JMeter (pdf link) but when running a recorded test against a Wicket application you have to be careful about recording and playing back tests so that that the test begins with a freshly created session. This is required to ensure that the number that appears in the "wicket:interface" parameter in the URL starts from 1 and is in sync with your script.
...
Recording can help a lot for e.g. to understand what exactly is being POST-ed when you have complex form submissions etc. but described below is an approach using JMeter regular expression support to arrive at stable and repeatable test scripts for Wicket applications.
...
The content of the "href" attribute can be grabbed using the following regex.
No Format |
---|
"([^"].+:create:[^"].+?)" |
The interesting thing here is that this is a "generic" regex. If you know the "wicket:id", this will work for all linksany link.
Within JMeter, you can add a "Regular Expression Extractor" listener post-processor to any requested page in your test script like this. This is how the above regex will look like: (the regex in the screenshot looks a bit different but does the exact same thing, for more information about the difference - look towards the end of this page)
The "$1$" refers to the content matched by the first regular expression that we have surrounded with brackets. In this case there is only one bracketed expression.
...
And the regex required is exactly the same as handling a link:
No Format |
---|
"([^"].+:form:[^"].+?)" |
Using this is almost the same as a link but this time we set the request method to POST and we also provide the expected request parameters.
...
There is one more corner case we need to consider. The wicket Link class allows you to nest an anchor tag within some other HTML tag use non-anchor HTML tags as links, for e.g. a TD tag. So if you have:
No Format |
---|
<td wicket:id="new"><a href="#">Click Me</a></td> |
RuntimeWicket generates some "onclick" javascript at runtime:
No Format |
---|
<td wicket:id="new" onclick="window.location.href='?wicket:interface=:4:header:new::ILinkListener:';return false;"> <a href="#">Click Me</a></td> |
The formula for this is slightly different - single quotes instead of double quotes.
No Format |
---|
'([^'].+:new:[^'].+?)' |
Conclusion
If you know the "wicket:id"s, creating repeatable JMeter tests for Wicket apps could be easier than creating them for normal web applications!
...
Sometimes you have a list of checkboxes and it may turn out that the "value" attribute being generated by Wicket is dynamic. I guess that a way to avoid having the "value" dynamic is to provide an IchoiceRenderer IChoiceRenderer where the getIdValue() is predictable instead of being generated by Wicket.
...
You can get the value you are interested in corresponding to the string "My Label" in this case like this:
No Format |
---|
<input value="([^"].+?)".*\n.*My Label |
You can easily submit the value of the "myradio" parameter in the next GET or POST request by using a JMeter variable (e.g. ${myradio})
Tip: Paste the browser HTML source into some text editor that supports regex searches (like Textpad) and then some trial and error will narrow down the regex that fits your requirement.
...
I have not yet tried to test any Ajax functionality with this approach. However I think that if you record a JMeter test involving Ajax requests and analyze the requests, you should be able to easily derive the steps and regular expressions required. If you have any success with this, please let me know (Peter Thomas) or inform the Wicket users mailing list or better still, please update this wiki page. Thanks!