Package org.apache.jmeter.extractor
Class XPath2Extractor
java.lang.Object
org.apache.jmeter.testelement.AbstractTestElement
org.apache.jmeter.testelement.AbstractScopedTestElement
org.apache.jmeter.extractor.XPath2Extractor
- All Implemented Interfaces:
- Serializable,- Cloneable,- Searchable,- 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 Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.apache.jmeter.testelement.TestElementorg.apache.jmeter.testelement.TestElement.Companion
- 
Field SummaryFieldsFields inherited from interface org.apache.jmeter.testelement.TestElementCOMMENTS, Companion, ENABLED, GUI_CLASS, NAME, TEST_CLASS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanShould we return fragment as text, rather than text of fragment?intReturn which Match to use.Return which Match to use.voidprocess()Do the job - extract value from (X)HTML response using XPath Query.voidsetDefaultValue(String val) voidsetFragment(boolean selected) Should we return fragment as text, rather than text of fragment?voidsetMatchNumber(int matchNumber) Set which Match to use.voidsetMatchNumber(String matchNumber) Set which Match to use.voidsetNamespaces(String namespaces) voidsetRefName(String refName) voidsetXPathQuery(String val) Methods inherited from class org.apache.jmeter.testelement.AbstractScopedTestElementfetchScope, getProps, getSampleList, getSchema, getScopeName, getVariableName, isScopeAll, isScopeChildren, isScopeParent, isScopeVariable, isScopeVariable, setScopeAll, setScopeChildren, setScopeParent, setScopeVariableMethods inherited from class org.apache.jmeter.testelement.AbstractTestElementaddPropertiesValues, addProperty, addProperty, addTestElement, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traversePropertyMethods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.jmeter.testelement.TestElementget, get, get, get, get, get, get, get, get, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getPropertyOrNull, getString, removed, removeProperty, set, set, set, set, set, set, set, set, set
- 
Field Details- 
DEFAULT_VALUE_AS_STRING
 
- 
- 
Constructor Details- 
XPath2Extractorpublic XPath2Extractor()
 
- 
- 
Method Details- 
processpublic 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:
- processin interface- PostProcessor
 
- 
setXPathQuery
- 
getXPathQuery
- 
setRefName
- 
getRefName
- 
setDefaultValue
- 
getDefaultValue
- 
getFragmentpublic boolean getFragment()Should we return fragment as text, rather than text of fragment?- Returns:
- true if we should return fragment rather than text
 
- 
setFragmentpublic void setFragment(boolean selected) Should we return fragment as text, rather than text of fragment?- Parameters:
- selected- true to return fragment.
 
- 
setMatchNumberpublic void setMatchNumber(int matchNumber) Set which Match to use. This can be any positive number, indicating the exact match to use, or0, which is interpreted as meaning random.- Parameters:
- matchNumber- The number of the match to be used
 
- 
setMatchNumberSet which Match to use. This can be any positive number, indicating the exact match to use, or0, which is interpreted as meaning random.- Parameters:
- matchNumber- The number of the match to be used
 
- 
getMatchNumberpublic int getMatchNumber()Return which Match to use. This can be any positive number, indicating the exact match to use, or0, which is interpreted as meaning random.- Returns:
- matchNumber The number of the match to be used
 
- 
getMatchNumberAsStringReturn which Match to use. This can be any positive number, indicating the exact match to use, or0, which is interpreted as meaning random.- Returns:
- matchNumber The number of the match to be used
 
- 
setNamespaces
- 
getNamespaces
 
-