Jmeter:Xpath获取文本达到一定数量的字符

时间:2017-03-14 07:12:43

标签: jmeter

从下面的片段我想获得标题为我的状态报告(ABCDEFGH12160916)     我的html中有数以千计的标题。     // td [@class =" dealertitle"] // text() - 这让我感到惊讶     我的状态报告(ABCDEFGH12160916)     * Live,Billable,CRM *

 I have also tried 
//td[@class="dealertitle"]//text()//substring-before(text(),')')---                                                                                                             

Jmeter does not allow me to use substring-before. It says unknown node type
 substring-before

 Can someone please help me. 
 I want to get this text till the end - My status   Report   (ABCDEFGH12160916)

            <html>
            <head>
           <body>
          <table class="secondhead" width="100%" cellspacing="0" cellpadding="0">
           <tbody>
           <tr>
            <td class="title">
            My status Report (ABCDEFGH12160916)
            <span style="font-size:14pt;color:#00FF00"> * Live, Billable, CRM *                                                                          
           </span>
           </td>
           </tr>
           </tbody>
          </table>
          </body>
          </head>
          </html>

2 个答案:

答案 0 :(得分:1)

// td [@ class =“dealertitle”] // text()[1]

答案 1 :(得分:1)

您的XPath查询中还有一个/

您的查询:

 //td[@class="dealertitle"]//text()

正确查询:

//td[@class="dealertitle"]/text()

演示:

JMeter Xpath Tester

说明:根据XPath Syntax article

  

/从根节点

中选择      

//从当前节点中选择与选项匹配的文档中的节点,无论它们在何处

有关在JMeter测试中使用XPath进行关联的更多详细信息,请参阅Using the XPath Extractor in JMeter指南。