Celso
Celso

Reputation: 13

Use XPath in JMeter to get attribute value

Below is a sample response from JMeter tool.

<input name="requestId" type="hidden" value="-1859748216"/>

I try the following XPath //input[@name='requestId'], but it doesn't work, I would like to take only the numeric value -1859748216

1

Upvotes: 1

Views: 1659

Answers (2)

Dmitri T
Dmitri T

Reputation: 168227

If you really want to use XPath, you need something like //input[@name='requestId']/@value

enter image description here

However XPath Extractor is quite resource intensive as it keeps entire DOM in memory, when it comes to getting the values from HTML content I would rather recommend going for CSS Selector Extractor leaving XPath for XML or when CSS Selectors are not powerful enough

Example setup:

enter image description here

More information:

Upvotes: 0

Ori Marko
Ori Marko

Reputation: 58902

You need to get the value attribute using /@value

//input[@name='requestId']/@value

Prefer using newer/improved XPath2 Extractor over XPath Extractor

Upvotes: 1

Related Questions