fix(接口定义):修复xpath提取器问题

--bug=1007706 --user=赵勇 【github#6222】响应体是html格式,用相同的方法在jmeter里可以提取到信息,在MS无法提取信息 https://www.tapd.cn/55049933/s/1067474
This commit is contained in:
fit2-zhao 2021-11-15 14:35:13 +08:00 committed by fit2-zhao
parent f9de1d0ed0
commit 7edd9799b6
1 changed files with 6 additions and 6 deletions

View File

@ -10,7 +10,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.extractor.JSR223PostProcessor; import org.apache.jmeter.extractor.JSR223PostProcessor;
import org.apache.jmeter.extractor.RegexExtractor; import org.apache.jmeter.extractor.RegexExtractor;
import org.apache.jmeter.extractor.XPath2Extractor; import org.apache.jmeter.extractor.XPathExtractor;
import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor; import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor;
import org.apache.jmeter.save.SaveService; import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.TestElement;
@ -94,16 +94,16 @@ public class MsExtract extends MsTestElement {
return extractor; return extractor;
} }
private XPath2Extractor xPath2Extractor(MsExtractXPath extractXPath, StringJoiner extract) { private XPathExtractor xPath2Extractor(MsExtractXPath extractXPath, StringJoiner extract) {
XPath2Extractor extractor = new XPath2Extractor(); XPathExtractor extractor = new XPathExtractor();
extractor.setEnabled(this.isEnable()); extractor.setEnabled(this.isEnable());
extractor.setTolerant(true);
extractor.setName(StringUtils.isNotEmpty(extractXPath.getVariable()) ? extractXPath.getVariable() : this.getName()); extractor.setName(StringUtils.isNotEmpty(extractXPath.getVariable()) ? extractXPath.getVariable() : this.getName());
if(StringUtils.isEmpty(extractor.getName())){ if(StringUtils.isEmpty(extractor.getName())){
extractor.setName("XPath2Extractor"); extractor.setName("XPath2Extractor");
} }
/*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " XPath2Extractor");*/ extractor.setProperty(TestElement.TEST_CLASS, XPathExtractor.class.getName());
extractor.setProperty(TestElement.TEST_CLASS, XPath2Extractor.class.getName()); extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPathExtractorGui"));
extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2ExtractorGui"));
extractor.setRefName(extractXPath.getVariable()); extractor.setRefName(extractXPath.getVariable());
extractor.setXPathQuery(extractXPath.getExpression()); extractor.setXPathQuery(extractXPath.getExpression());
if (extractXPath.isMultipleMatching()) { if (extractXPath.isMultipleMatching()) {