Class XPath2Extractor

All Implemented Interfaces:
Serializable, Cloneable, Searchable, PostProcessor, TestElement

public class XPath2Extractor extends AbstractScopedTestElement implements PostProcessor, Serializable
Extracts text from (X)HTML response using XPath query language Example XPath queries:
/html/head/title
extracts Title from HTML response
//form[@name='countryForm']//select[@name='country']/option[text()='Czech Republic'])/@value
extracts value attribute of option element that match text 'Czech Republic' inside of select element with name attribute 'country' inside of form with name attribute 'countryForm'
//head
extracts the XML fragment for head node.
//head/text()
extracts the text content for head node.
see org.apache.jmeter.extractor.TestXPathExtractor for unit tests
See Also:
  • Field Details

    • DEFAULT_VALUE_AS_STRING

      public static final String DEFAULT_VALUE_AS_STRING
  • Constructor Details

    • XPath2Extractor

      public XPath2Extractor()
  • Method Details

    • process

      public void process()
      Do the job - extract value from (X)HTML response using XPath Query. Return value as variable defined by REFNAME. Returns DEFAULT value if not found.
      Specified by:
      process in interface PostProcessor
    • setXPathQuery

      public void setXPathQuery(String val)
    • getXPathQuery

      public String getXPathQuery()
    • setRefName

      public void setRefName(String refName)
    • getRefName

      public String getRefName()
    • setDefaultValue

      public void setDefaultValue(String val)
    • getDefaultValue

      public String getDefaultValue()
    • getFragment

      public boolean getFragment()
      Should we return fragment as text, rather than text of fragment?
      Returns:
      true if we should return fragment rather than text
    • setFragment

      public void setFragment(boolean selected)
      Should we return fragment as text, rather than text of fragment?
      Parameters:
      selected - true to return fragment.
    • setMatchNumber

      public void setMatchNumber(int matchNumber)
      Set which Match to use. This can be any positive number, indicating the exact match to use, or 0, which is interpreted as meaning random.
      Parameters:
      matchNumber - The number of the match to be used
    • setMatchNumber

      public void setMatchNumber(String matchNumber)
      Set which Match to use. This can be any positive number, indicating the exact match to use, or 0, which is interpreted as meaning random.
      Parameters:
      matchNumber - The number of the match to be used
    • getMatchNumber

      public int getMatchNumber()
      Return which Match to use. This can be any positive number, indicating the exact match to use, or 0, which is interpreted as meaning random.
      Returns:
      matchNumber The number of the match to be used
    • getMatchNumberAsString

      public String getMatchNumberAsString()
      Return which Match to use. This can be any positive number, indicating the exact match to use, or 0, which is interpreted as meaning random.
      Returns:
      matchNumber The number of the match to be used
    • setNamespaces

      public void setNamespaces(String namespaces)
    • getNamespaces

      public String getNamespaces()