The JMeter XPath Assertion (classname: org.jmeter.components.assertions.XpathAssertion) component does not work for a subset of XPath queries. Current behaviour: The XpathAssertion *only* works for XPath queries which return a NodeList. For any other queries that return a non-NodeList result, XpathAssertion fails with a TransformerException. Eg: <response> <code>1</code> <error>Print Error</error> <error>Network Error</error> </response> XpathAssertion works for //*[code=1] XpathAssertion does not work for count(//*error)=2 {this is valid XPath} It returns a TransformerException. Proposed Solution: We need additional meat in XpathAssertion#getResult(SampleResult): 1. Use generic XPathAPI.eval, instead of XPathAPI.selectNodeList 2. Make decision based on the return value of point 1. a. If NodeList, do as earlier. b. If boolean, then fail if false, else pass. c. So on for other types. After the fix, the following assertions must be successful, <response> <code>1</code> <error>Print Error</error> <error>Network Error</error> </response> Query 1 count(//*error)=2 Query 2 count(//*[code=1])=1 These would be unsuccessful: Query 3 count(//*error)=1 Query 4 count(//*[code=2])=1 (Further tests can be added, depending on what return values from XPath queries are being supported - boolean, number etc)
Added to SVN in r529081
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1907