2011-10-25 54 views
0

我需要attr。价值componentIdinteractionstate从HTML通过JMeter,我尝试与XPath提取器,但我不能这样做。如何从JMeter中的XPath提取器的响应中提取属性?

<html> 
    <body> 
     ... 
     <form ...> 
     <form class="UIForm" id="UINavigationComposer" action="/portal/intranet/home?portal:componentId=d934d0f3-d465-4c1d-880a-45f54b3c48e2&amp;interactionstate=JBPNS_rO0ABXcwAAt1aWNvbXBvbmVudAAAAAEAFFVJTmF2aWdhdGlvbkNvbXBvc2VyAAdfX0VPRl9f&amp;portal:type=action" method="post"> 
     <form ...> 
     ... 
    </body> 
</html> 

我尝试使用XPath查询:

/html/body/[email protected][id=UINavigationComposer]/@action 

但得到的错误:

Assertion failure message: /html/body/[email protected][id=UINavigationComposer]; => The reference to entity "portal:action" must end with the ';' delimiter.

回答

2

我认为你必须在你的XPath查询一点点流逝。 把@附近的ID属性像下面

/html/body/form[@id=UINavigationComposer]/@action 

或使用这样的:

//form[@id='UINavigationComposer']/@action 

所以,第一步 - 提取完整的行动值,并将其存储在单独的JMeter变量(例如ACTION_TEST),使用RegEx或Xpath Extractor。
第二步 - 从这个变量值中提取componentId和interactionstate。
jmeter 2.5(自2.3.2,afair开始)的RegEx Extractor具有选项“Apply to ... Jmeter Variable”。
您可以在“应用到...的JMeter变量”选项,并correcponding查询添加2个额外的正则表达式的每个脱水机使用$ {} ACTION_TEST:

componentId=(.+?); 
interactionstate=(.+?); 
  1. 提取得到充分的行动值与响应+保存到变量。
  2. 提取器以获取componentId值FROM VARIABLE。
  3. 提取器以获取交互状态值FROM VARIABLE。

希望这会起作用。

相关问题