문제

I have a question about grabbing a certain value from the html response data in Jmeter. I've been trying both regular expression and xpath extractor(see below) but having no luck.

This is part of the response data I receive:

<table border="0" cellpadding="2" cellspacing="1" style="border-collapse: collapse" id="AutoNumber2" bordercolorlight="#999999" bordercolordark="#999999" width="100%">
   <tr> 
      <td class="head" align="center" colspan="2">Routing Sheet</td>
   </tr>

   <tr class="altrow"> 
      <td align="right" width="50%" class="formtext">Today's Date:</td>
      <td valign="top" width="50%" class="formtext">06/19/2012</td>
   </tr>

   <tr class="altrow"> 
      <td align="right" width="50%" class="formtext"> HCSC Received Date:</td>
      <td valign="top" width="50%" class="formtext">06/19/2012</td>
   </tr>

   <tr class="tablerow"> 
      <td align="right" width="50%" class="formtext"> Package Log Date:</td>
      <td valign="top" width="50%" class="formtext">06/19/2012 04:21PM</td>
   </tr>

   <tr class="altrow"> 
      <td align="right" width="50%" class="formtext"> Group Specialist:</td>   
      <td valign="top" width="50%" class="formtext">WATTS, JOHN</td>            
   </tr>

   <tr class="tablerow"> 
      <td align="right" width="50%" class="formtext"> Case Underwriter:</td>
      <td valign="top" width="50%" class="formtext">N/A</td>           
   </tr>    

   <tr class="altrow"> 
       <td align="right" width="50%" class="formtext"> Medical Underwriter:</td>  
       <td valign="top" width="50%" class="formtext">N/A</td>    
   </tr>

   <tr class="tablerow"> 
       <td align="right" width="50%" class="formtext">Case Number:</td>                           
       <td valign="top" width="50%" class="formtext">7402628</td>
   </tr>

And I'm trying to grab the case number. I have been trying the regex extractor:

Case Number:</td><td valign="top" width="50%" class="formtext">(.+?)</td>

But got a null value back.

And for xpath extractor I tried this:

//table[@id='AutoNumber2']/tbody/tr[8]/td[2]

but it's not working either. I've been thinking of using Beanshell to grab the source code as a string and parse the number. Is there any better way of grabbing that number? And how can I use beanshell to grab the source code of the response data? I tried using xpath of /html but have no luck.

Thanks a lot

도움이 되었습니까?

해결책

Try this xpath:

//table[@id='AutoNumber2']/tr[8]/td[2]

다른 팁

Try this, I tested it on your sample and it works :

enter image description here

Let me know if that works for you

  1. If you are using XPath Extractor to parse HTML (not XML!..) response ensure that Use Tidy (tolerant parser) option is CHECKED.

  2. Your xpath query should return value you want to extract.
    Refine your xpath query, e.g.

    //table[@id='AutoNumber2']/tbody/tr[td/text()='Case Number:']/td[2]/text()

  3. To use Beanshell for parsing look into this: Using jmeter variables in xpath extractor.

  4. You can first test your xpath query using any other tool - Firefox addons at least:

You can use ViewResultsTree listener component to test and tweak your regex expression on your actual response data.

To find out what happens in runtime use Debug component.

At the first glance I see that it doesn't match because you're missing new line in your regex expression (following Case Number:</td>).

See here for special characters that emulate new line.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top