I have a requirement to fetch the ID of a <tr> tag based on the country name (TestIndia1). I am trying to edit the record, but while editing, it requires the ID.

So please let me know how to fetch the ID from the html using a regular expression.

<tr role="row" id="241" tabindex="-1" class="ui-widget-content jqgrow ui-row-ltr">
    <td role="gridcell" style="text-align:center;width: 30px;" aria-describedby="list2_cb">
    <input role="checkbox" type="checkbox" id="jqg_list2_241" class="regular-checkbox cbox" name="jqg_list2_241"><label for="jqg_list2_241">
    </label></td><td role="gridcell" aria-describedby="list2_subgrid" class="ui-sgcollapsed sgcollapsed " style="">
    <a style="cursor:pointer;"><span class="ui-icon ui-icon-plus"></span></a></td>
    <td role="gridcell" style="text-align:left;" aria-describedby="list2_mc_country"><a class="inline-edit-link " href="http://example.com|id|241">TestIndia1</a></td>

1 Answer 1

  1. Add XPath Extractor as a child of the request which returns that HTML
  2. Configure it as follows:

    • If response is not XHTML-compliant check Use Tidy box
    • Reference Name: arbitrary JMeter Variable name, i.e. ID
    • XPath Query: //a[text()='TestIndia1']/ancestor::*/tr/@id
  3. Refer the extracted value as ${ID} where required.

Useful links:

  • Thanks for your answer @Dmitri , I need the same in regular extractor, because in response I am getting the json data. So I dont have chance to use xpath extractor
    – QAMember
    Jun 15, 2015 at 5:51
  • 1
    There is a JSON Path Extractor plugin which works fine with JSON data. It's described in aforementioned "Using the XPath Extractor in JMeter guide", just scroll down to "Parsing JSON" section.
    – Dmitri T
    Jun 16, 2015 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.