sri
sri

Reputation: 21

Regular Expression for span text in jmeter

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):

Upvotes: 0

Views: 565

Answers (2)

Dmitri T
Dmitri T

Reputation: 168092

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.

Upvotes: 0

vins
vins

Reputation: 15390

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

Upvotes: 1

Related Questions