Start JMeter, add a Thread group Test Plan → Add→ Threads(Users)→ Thread Group.
As we want to extract two pieces of information from this page, the person ID and the person name, the fields are defined as follows − We can use this to match the exact pattern that we want to extract information from. To capture the ID of this person, let us first determine the pattern where we will find the person in the second row.Īs can be seen in the following snapshot, the ID of the second person is surrounded by and, and it is the second row of data having this pattern. In our test plan, we will select the person in the first row of the person table seen in the person list page above. The contents of html (index.html) are as follows deploying it on the tomcat server, this page would look like as shown in the following screenshot − This element extracts text from the current page using a Regular Expression to identify the text pattern that a desired element conforms with.įirst we write an HTML page which a list of people and their email IDs. Let us understand the use of Regular expressions in the Regular Expression Extractor-a Post-Processor Element by writing a test plan. ( and ) − these enclose the portion of the match string to be returned Suppose you want to match the following portion of a web-page −Īnd you want to extract readme.txt. Hence the 'alphabet' is "matched" by 'al.*t'. Matches means that the regular expression matched the whole target. It is worth stressing the difference between contains and matches, as used on the Response Assertion test element −Ĭontains means that the regular expression matched at least some part of the target, so 'alphabet' "contains" 'ph.b.' because the regular expression matches the substring 'phabe'. You can place regular expressions in any component in a Test Plan. To use regular expressions in your test plan, you need to use the Regular Expression Extractor of JMeter. If the server returns a unique session key we can easily get it using expressions in our load script.
A standard usage example of using expressions is to get a session ID from the server response. Regular expressions provide a simple method to get information from pages when it is impossible or very hard to predict an outcome. With the use of regular expressions, we can certainly save a lot of time and achieve greater flexibility as we create or enhance a Test Plan.
JMeter interprets forms of regular expressions or patterns being used throughout a JMeter test plan, by including the pattern matching software Apache Jakarta ORO. Href=".-.-(.*)_0\.ice#">Some Static Stringīut it doesn't work when I apply it to my extraction rule.Regular expressions are used to search and manipulate text, based on patterns. I have come up with the following regex which seems to work fine online: I need to extract the following id from the href of each message: I get large resultat of HTML from my calls. The problem I am having is that the REGEX seems to work fine when I test it online with different tools,īut is not giving me the expected result when used within an extraction rule. I have a REGEX I need to use to extract a particular ID from a response in one of my tests with Visual Studio Web Performance and Load Testing.