Class XPath2Extractor

  • All Implemented Interfaces:
    java.io.Serializable , java.lang.Cloneable , org.apache.jmeter.gui.Searchable , org.apache.jmeter.processor.PostProcessor , org.apache.jmeter.testelement.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
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      void process() Do the job - extract value from (X)HTML response using XPath Query.
      void setXPathQuery(String val)
      String getXPathQuery()
      void setRefName(String refName)
      String getRefName()
      void setDefaultValue(String val)
      String getDefaultValue()
      boolean getFragment() Should we return fragment as text, rather than text of fragment?
      void setFragment(boolean selected) Should we return fragment as text, rather than text of fragment?
      void setMatchNumber(int matchNumber) Set which Match to use.
      void setMatchNumber(String matchNumber) Set which Match to use.
      int getMatchNumber() Return which Match to use.
      String getMatchNumberAsString() Return which Match to use.
      void setNamespaces(String namespaces)
      String getNamespaces()
      • Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

        addTestElement, canRemove, clear, clearTestElementChildren, clone, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse
      • Methods inherited from class org.apache.jmeter.testelement.AbstractScopedTestElement

        fetchScope, getProps, getSchema, getVariableName, isScopeAll, isScopeChildren, isScopeParent, isScopeVariable, setScopeAll, setScopeChildren, setScopeParent, setScopeVariable
      • Methods inherited from class org.apache.jmeter.testelement.TestElement

        get, get, get, get, get, get, get, get, get, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getProps, getSchema, getString, removed, set
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XPath2Extractor

        XPath2Extractor()
    • Method Detail

      • process

         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.

      • getFragment

         boolean getFragment()

        Should we return fragment as text, rather than text of fragment?

        Returns:

        true if we should return fragment rather than text

      • setFragment

         void setFragment(boolean selected)

        Should we return fragment as text, rather than text of fragment?

        Parameters:
        selected - true to return fragment.
      • setMatchNumber

         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

         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

         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

         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