HomeHome ArchiveArchive

Extracting text from a page and using it somewhere else in JMeter

(This article is part of the JMeter Series)

In the following we’ll do these things:

  1. we go to a form submit page
  2. we order something
  3. we get that something we ordered

Overwiev Screenshot

In more detail:

Details Screenshot

Cookie Manager Screenshot

We set up our variables

User Variables Screenshot

The idea here being that we predefine the variables, so they would show up in the “Debug Sampler” which makes debugging easier, because you see at each step, whether the variable has the correct value or not. I do predefine the variables with a “non-value” so that I can see immediately whether the variable has been already assigned something during the execution of the test or not.

We go to a form submit page

Get Form Screenshot

We extract the AUTHTOKEN from that form

(The auth token is being used by the web application to prevent cross-site-scripting)

Extract AUTHTOKEN Screenshot

Notice that the extractor is set to extract the string from the HTTP reply-body.

This is because we want to pass the cookie to an outside application, so that it can call the web app from within the same session.

Extract Session Cookie Screenshot

Notice that this time we told the extractor to extract the string from the HTTP reply-headers.

We now use all our extracted parameters to submit our order

Submit Screenshot

Note that:

  • we are passing the AUTHTOKEN along with the HTTP POST
  • since we are not sure whether possibly the AUTHTOKEN contains some problematic character (in my case it was an equal sign ‘=’ that was interferring with the parameter encoding) we tell JMeter to URL-encode the string.
  • we also pass along another parameter telling the web app what we’re interested in getting back from our order
  • we are using HTTPS

Submitting the order will redirect us to the page that’ll show us the resulting order.

We extract the ORDER_ID from HTTP headers which would otherwise redirect us to the resulting page

The headers contain the location of the resulting order page where we would be redirected to.

Extract Order ID Screenshot

Finally we download the resulting artefact with curl

Download with Curl Screenshot

Note that:

  • we are passing the SESSION_COOKIE to curl to be able to download the artifact in the same (potentially authenticated) session.

  • we also construct the download URL from the ORDER_ID

You can download this JMeter test from here

Tomáš Pospíšek, 4.1.2011

Debugging JMeter Tests

(This article is part of the JMeter Series)

Useful ways to debug JMeter as far as I know:

  • insert a “Debug Sampler”

Debug Sampler Screenshot

the “Debug Sampler” will emit “everything that’s known” to JMeter. That output can be displayed in the “View Results Tree Listener”:

Debug Sampler Result Screenshot

  • have a look at the JMeter log file (which is usually dumped from where you’ve started JMeter)

  • check the output of one of the listeners such as the “View Results Tree Listener”.

  • if you need to debug regexes of a “Regular Expression Extractor” then you can have a look at the source code of the page you want to extract a value from inside the “View Results Tree Llistener” and enter the same regular expression in the “Search” field (searching is only implemented in JMeter > v2.4).

Debugging Regexes Screenshot

In that picture you can see JMeter matching and displaying the regex entered in the search field inside an HTML page retrieved though the “HTTP Client Sampler”.

Tomáš Pospíšek, 1.1.2011

New label tools in QGIS

In cartography, it is a frequent operation to set labels to fixed positions, together with the position of the fix point (left/middle/right, Top, Half, Bottom) that is kept constant in case of font change, rotation or zoom. Therefore, three new editing tools to manipulate text labels are now in the QGIS developer version:

  1. the move label tool drags text labels to a new position

Move label

  1. the rotate label tool is for interactive rotation of labels
  2. the label property tools opens a dialog that lets the user manipulate the data defined properties of a label (and also the text of the label attribute)

Move label

All three tools work on the new labeling engine and data defined labeling needs to be enabled for the layer (e.g. x coordinate attribute / y coordinate attribute for the move tool, rotation for the rotate tool). Additionally, the layer needs to be in edit mode. The new tools are well suited to mix fixed label positions and automated label opsitioning in the same or among several layers. If the x- or y attribute value is NULL, the position is set automatically by the pal library (http://pal.heig-vd.ch/). As soon as a position is manipulated by the move label tool, the position is written into the attribute field and the label position for this feature is fixed. So if a layer does not yet have attribute fields for x, y, you could create two new fields of type double (using the buttons in the vector properties dialog or in the attribute table). Initially, all values will be ‘NULL’ and all the label positions set automatically.

There are further plans to improve the user interface. It could be handy to have the properties dialog always open (non-modal), which would allow faster edits of a large number of labels. And a live text rotation preview is planned too. And yes, if someone likes making real icons, this would be highly appreciated (my graphical skills are somewhat limited…).

Finally I’d like to thank the city of Thun (Switzerland) for funding these tools and sharing it with the rest of the FOSSGIS world.