美文网首页
Regular Expression Extractor

Regular Expression Extractor

作者: 怪物猎人 | 来源:发表于2017-04-19 11:07 被阅读0次

    Reference

    正则表达式

    What it is

    Allows the user to extract values from a server response using a Perl-type regular expression. As a post-processor, this element will execute after each Sample request in its scope, applying the regular expression, extracting the requested values, generate the template string, and store the result into the given variable name.

    Attribute

    </br>

    How use

    
    <?xml version="1.0" encoding="UTF-8"?>
    <jmeterTestPlan version="1.2" properties="3.1" jmeter="3.1 r1770033">
      <hashTree>
        <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划" enabled="true">
          <stringProp name="TestPlan.comments"></stringProp>
          <boolProp name="TestPlan.functional_mode">false</boolProp>
          <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
          <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="TestPlan.user_define_classpath"></stringProp>
        </TestPlan>
        <hashTree>
          <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="线程组" enabled="true">
            <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
            <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true">
              <boolProp name="LoopController.continue_forever">false</boolProp>
              <stringProp name="LoopController.loops">1</stringProp>
            </elementProp>
            <stringProp name="ThreadGroup.num_threads">1</stringProp>
            <stringProp name="ThreadGroup.ramp_time">1</stringProp>
            <longProp name="ThreadGroup.start_time">1492565762000</longProp>
            <longProp name="ThreadGroup.end_time">1492565762000</longProp>
            <boolProp name="ThreadGroup.scheduler">false</boolProp>
            <stringProp name="ThreadGroup.duration"></stringProp>
            <stringProp name="ThreadGroup.delay"></stringProp>
          </ThreadGroup>
          <hashTree>
            <kg.apc.jmeter.samplers.DummySampler guiclass="kg.apc.jmeter.samplers.DummySamplerGui" testclass="kg.apc.jmeter.samplers.DummySampler" testname="jp@gc - Dummy Sampler" enabled="true">
              <boolProp name="WAITING">true</boolProp>
              <boolProp name="SUCCESFULL">true</boolProp>
              <stringProp name="RESPONSE_CODE">200</stringProp>
              <stringProp name="RESPONSE_MESSAGE">OK</stringProp>
              <stringProp name="REQUEST_DATA">Dummy Sampler used to simulate requests and responses
    without actual network activity. This helps debugging tests.</stringProp>
              <stringProp name="RESPONSE_DATA">{
        "sysNo": "11111",
        "skuid": "487626525247",
        "productID": "101-006-72958",
        "productTitle": "苹果(Apple)iPhone 6 Plus (A1524) 16GB 金色 移动联通电信4G手机",
        "price": "556600",
        "activePrice": "",
        "sysNo": "22222",
        "marketprice": "608800",
        "promotionDesc": "A1524、A1586为三网通版,支持移动\/联通\/电信4G\/3G\/2G。找水货?找翻新?没有!易迅网为国行正品代言!!",
        "manufacturerCode": "49",
        "manufacturerName": "苹果(Apple)",
        "evaluationNum": "1717",
        "gradeNum": "48",
        "onlineQty": "796",
        "shippingday": "0t0",
        "gift": 0,
        "promotionType": "0",
        "attribute": "2000000000e214处理器;<strong>(为保持样式美观,此处有删减文字,请知悉!)</strong>;43257eFDD-LTE\/TD-LTE\-LTE)\/电信4G(FDD-LTE);移动3G(TD-SCDMA)\353e2;49e9?金色;42914?内存e1?16G;43246?制式e4?5.5寸三网通版",
        "saleNum": "454",
        "productTypeMasterid": "0",
        "areaCode": "1",
        "classid": "203320",
        "tag": "超薄手机 大屏手机 待机时间长 高清屏 女神手机 拍照功能强 商务手机 外观漂亮 指纹识别 主流潮机",
        "goodsUrl": "http:\/\/item.yixun.com\/item-2142717.html",
        "picUrl": "http:\/\/img3.wgimg.com\/qqbuy\/2295220799\/item-00000000000000000000007188CE4A3F.0.jpg\/200?55DAE367",
        "reachable": "0"
    },</stringProp>
              <stringProp name="RESPONSE_TIME">${__Random(50,500)}</stringProp>
              <stringProp name="LATENCY">${__Random(1,50)}</stringProp>
              <stringProp name="CONNECT">${__Random(1,5)}</stringProp>
            </kg.apc.jmeter.samplers.DummySampler>
            <hashTree>
              <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="正则表达式提取器" enabled="true">
                <stringProp name="RegexExtractor.useHeaders">false</stringProp>
                <stringProp name="RegexExtractor.refname">goodsid</stringProp>
                <stringProp name="RegexExtractor.regex">"(sysNo)": "(.+?)",</stringProp>
                <stringProp name="RegexExtractor.template">$2$</stringProp>
                <stringProp name="RegexExtractor.default">ERROR</stringProp>
                <stringProp name="RegexExtractor.match_number">2</stringProp>
              </RegexExtractor>
              <hashTree/>
            </hashTree>
            <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
              <boolProp name="displayJMeterProperties">false</boolProp>
              <boolProp name="displayJMeterVariables">true</boolProp>
              <boolProp name="displaySystemProperties">false</boolProp>
            </DebugSampler>
            <hashTree/>
            <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="察看结果树" enabled="true">
              <boolProp name="ResultCollector.error_logging">false</boolProp>
              <objProp>
                <name>saveConfig</name>
                <value class="SampleSaveConfiguration">
                  <time>true</time>
                  <latency>true</latency>
                  <timestamp>true</timestamp>
                  <success>true</success>
                  <label>true</label>
                  <code>true</code>
                  <message>true</message>
                  <threadName>true</threadName>
                  <dataType>true</dataType>
                  <encoding>false</encoding>
                  <assertions>true</assertions>
                  <subresults>true</subresults>
                  <responseData>false</responseData>
                  <samplerData>false</samplerData>
                  <xml>true</xml>
                  <fieldNames>true</fieldNames>
                  <responseHeaders>false</responseHeaders>
                  <requestHeaders>false</requestHeaders>
                  <responseDataOnError>false</responseDataOnError>
                  <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
                  <assertionsResultsToSave>0</assertionsResultsToSave>
                  <bytes>true</bytes>
                  <sentBytes>true</sentBytes>
                  <threadCounts>true</threadCounts>
                  <idleTime>true</idleTime>
                  <connectTime>true</connectTime>
                </value>
              </objProp>
              <stringProp name="filename"></stringProp>
            </ResultCollector>
            <hashTree/>
          </hashTree>
        </hashTree>
      </hashTree>
    </jmeterTestPlan>
    
    
    

    output:

    相关文章

      网友评论

          本文标题:Regular Expression Extractor

          本文链接:https://www.haomeiwen.com/subject/cysczttx.html