Reputation: 801
I have a list of links in a table. One link from table is shown below:
<a href="/hix/entity/assisteradmin/viewassisterinformation?assisterId=CSyTid9fDmtJ4OqoMA3mvA">
A1 Counselor
</a>
in an HTML response in JMeter.
I am trying to get the value of assisterId (CSyTid9fDmtJ4OqoMA3mvA) from the href link text from the HTML response through JMeter.
Can someone please help me through this?
Upvotes: 0
Views: 1840
Reputation: 73
Following the answer of har07, you could use a XPath extractor as a child of the HTTP Request sampler from which you get the list of links.
The major drawback of the XPath extractor is that it won't work if Tidy errors are returned.
Consider using a Regular Expression extractor instead, as it would work at all time if your regular expression match the HTML response returned by the server.
In your case the regex and the other Regex extractor parameters would be like :
ASSISTER_ID
<a href=".*?viewassisterinformation\?assisterId=(.*?)">
ASSISTER_ID
) : $1$
1
REGEX_FAILED
In case you want to process all the links from the list, set the Match No. to -1
and use it with a ForEach Controller.
Upvotes: 1
Reputation: 168082
You can get this value via Regular Expression Extractor as:
Configure it as follows:
assisterId
<a href="/hix/entity/assisteradmin/viewassisterinformation\?assisterId=(.+?)">
$1$
${assisterId}
where requiredSee USING REGULAR EXPRESSION EXTRACTOR guide for more details on correlation in JMeter using regular expressions.
Upvotes: 0
Reputation: 89285
I'm not familiar with JMeter, but in xpath point of view, you can try using substring-after()
function to extract text that occurs after "assisterId="
, something like this :
substring-after(//a/@href, 'assisterId=')
output in xpath tester, given the above HTML snippet as input :
String='CSyTid9fDmtJ4OqoMA3mvA'
Upvotes: 1