Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting value from HTML Responce using Regular expression in JMETER?

Tags:

html

regex

jmeter

I am getting response from Jmeter like this:

<input type="hidden" id="queueItemId" name="queueItemId" value="3256"/>

I wanted to get value 3256 from this and store it in a variable. Then i can use this variable further use like ${variable}. For this i am using RegularExpressionExtractor in scope of the Sampler.

Please give me the regular expression to extract this value.

like image 990
ayyappa Avatar asked May 31 '11 06:05

ayyappa


People also ask

What is regular expression extractor in JMeter?

In JMeter, the Regular Expression Extractor is useful for extracting information from the response. For example, when you request a page and then need to get a link from the page that was downloaded.

What is $1$ in JMeter?

$1$ to refers to group 1, $2$ to refers to group 2, etc. $0$ refers to whatever the entire expression matches.

What is match no in JMeter?

2.6 Match No. We have 3 kinds of Match No: Use a value of zero to indicate JMeter should choose a match at random. A positive number N means to select the nth match. Negative numbers are used to returns all matches.


2 Answers

Try something like:

encounterId=([0-9]+)

and use group 1 as the result.

like image 190
morja Avatar answered Oct 11 '22 16:10

morja


Better than using regular expression to extract that value I would suggest using XPath Extraction like this:

//form[@name='MyForm']//input[@name='queueItemId']/@value

Where MyForm is your form name, replace with whatever you have.

like image 20
anubhava Avatar answered Oct 11 '22 17:10

anubhava