0
votes

html code

<span id="nameDomain">gmail.com</span>

How to take the field values in Regular Expression extractor of jmeter

What i have to give

Regular Expression: Template: Match No.(0 for Random):

2

2 Answers

1
votes

You can check the below example to extract the value.

You need to use ${spanval} in the subsequent requests to access the value you have extracted.

enter image description here

Check this: JMeter - Regular Expression Extractor

0
votes

In general using regular expressions to parse HTML isn't a very good idea as regular expressions are very sensitive to markup change and very fragile.

You can use XPath Extractor instead.

  1. Add XPath Extractor as a child of the request which returns that "span" and configure it as follows:

    • Check Use Tidy box if response is not XHTML-compliant
    • Reference Name: anything meaningful, i.e. nameDomain
    • XPath Query: //span[@id='nameDomain']/text()
  2. Refer extracted value as ${nameDomain} where required.

See XPath Tutorial for language reference and Using the XPath Extractor in JMeter for some more details.


If you still want to use Regular Expressions, the relevant Regular Expression will be <span id="nameDomain">(\S+)</span> and Template $1$. Other fields (apart from the "Reference Name" may be left as they are.