<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    qileilove

    blog已經轉移至github,大家請訪問 http://qaseven.github.io/

    jmeter之前置處理器

    18.7.7 BeanShell PreProcessor

    The BeanShell PreProcessor allows arbitrary code to be applied before taking a sample.

    For full details on using BeanShell, please see the BeanShell website.

    The test element supports the ThreadListener and TestListener methods. These should be defined in the initialisation file. See the file BeanShellListeners.bshrc for example definitions.

    Control Panel

    Parameters

    AttributeDescriptionRequired
    NameDescriptive name for this element that is shown in the tree. The name is stored in the script variable LabelNo
    Reset bsh.Interpreter before each callIf this option is selected, then the interpreter will be recreated for each sample. This may be necessary for some long running scripts. For further information, see Best Practices - BeanShell scripting .Yes
    ParametersParameters to pass to the BeanShell script. The parameters are stored in the following variables:
    • Parameters - string containing the parameters as a single variable
    • bsh.args - String array containing parameters, split on white-space
    No
    Script fileA file containing the BeanShell script to run. The file name is stored in the script variable FileNameNo
    ScriptThe BeanShell script. The return value is ignored.Yes (unless script file is provided)

     

    Before invoking the script, some variables are set up in the BeanShell interpreter:

    • log - (Logger) - can be used to write to the log file
    • ctx - ( JMeterContext ) - gives access to the context
    • vars - ( JMeterVariables ) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object());
    • props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");
    • prev - ( SampleResult ) - gives access to the previous SampleResult (if any)
    • sampler - (Sampler)- gives access to the current sampler

    For details of all the methods available on each of the above variables, please check the Javadoc

    If the property beanshell.preprocessor.init is defined, this is used to load an initialisation file, which can be used to define methods etc for use in the BeanShell script.


    18.7.8 BSF PreProcessor

    The BSF PreProcessor allows BSF script code to be applied before taking a sample.

    Control Panel

    Parameters

    AttributeDescriptionRequired
    NameDescriptive name for this element that is shown in the tree.No
    LanguageThe BSF language to be usedYes
    ParametersParameters to pass to the script. The parameters are stored in the following variables:
    • Parameters - string containing the parameters as a single variable
    • args - String array containing parameters, split on white-space
    No
    Script fileA file containing the script to run, if a relative file path is used, then it will be relative to directory referenced by "user.dir" System propertyNo
    ScriptThe script to run.Yes (unless script file is provided)

     

    The script (or file) is processed using the BSFEngine.exec() method, which does not return a value.

    The following BSF variables are set up for use by the script:

    • log - (Logger) - can be used to write to the log file
    • Label - the String Label
    • Filename - the script file name (if any)
    • Parameters - the parameters (as a String)
    • args[] - the parameters as a String array (split on whitespace)
    • ctx - ( JMeterContext ) - gives access to the context
    • vars - ( JMeterVariables ) - gives read/write access to variables: vars.get(key); vars.put(key,val); vars.putObject("OBJ1",new Object()); vars.getObject("OBJ2");
    • props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");
    • sampler - (Sampler)- gives access to the current sampler
    • OUT - System.out - e.g. OUT.println("message")

    For details of all the methods available on each of the above variables, please check the Javadoc


    18.7.3 HTML Parameter Mask (DEPRECATED)

    *** This element is deprecated. Use Counter instead ***

    The HTML Parameter Mask is used to generate unique values for HTML arguments. By specifying the name of the parameter, a value prefix and suffix, and counter parameters, this modifier will generate values of the form " name=prefixcountersuffix ". Any HTTP Request that it modifies, it will replace any parameter with the same name or add the appropriate parameter to the requests list of arguments.

     

    The value of the argument in your HTTP Request must be a '*' in order for the HTML Parameter Mask Modifier to replace it.

     

    As an example, the username for a login script could be modified to send a series of values such as: 
    user_1 
    user_2 
    user_3 
    user_4, etc.

    Control Panel

    Parameters

    AttributeDescriptionRequired
    NameDescriptive name given to this element in the test tree.No
    Name (second appearing)The name of the parameter to modify or add to the HTTP Request.Yes
    ID PrefixA string value to prefix to every generated value.No
    Lower BoundA number value to start the counter at.Yes
    Upper BoundA number value to end the counter, at which point it restarts with the Lower Bound value.Yes
    IncrementValue to increment the counter by each time through.Yes
    ID SuffixA string value to add as suffix to every generated vaue.No

     



    18.7.2 HTTP URL Re-writing Modifier

    This modifier works similarly to the HTML Link Parser, except it has a specific purpose for which it is easier to use than the HTML Link Parser, and more efficient. For web applications that use URL Re-writing to store session ids instead of cookies, this element can be attached at the ThreadGroup level, much like the HTTP Cookie Manager . Simply give it the name of the session id parameter, and it will find it on the page and add the argument to every request of that ThreadGroup.

    Alternatively, this modifier can be attached to select requests and it will modify only them. Clever users will even determine that this modifier can be used to grab values that elude the HTML Link Parser .

    Control Panel

    Parameters

    AttributeDescriptionRequired
    NameDescriptive name given to this element in the test tree.No
    Session Argument NameThe name of the parameter to grab from previous response. This modifier will find the parameter anywhere it exists on the page, and grab the value assigned to it, whether it's in an HREF or a form.Yes
    Path ExtensionSome web apps rewrite URLs by appending a semi-colon plus the session id parameter. Check this box if that is so.No
    Do not use equals in path extensionSome web apps rewrite URLs without using an "=" sign between the parameter name and value (such as Intershop Enfinity).No
    Do not use questionmark in path extensionPrevents the query string to end up in the path extension (such as Intershop Enfinity).No
    Cache Session Id?Should the value of the session Id be saved for later use when the session Id is not present?Yes

     


    18.7.1 HTML Link Parser

    This modifier parses HTML response from the server and extracts links and forms. A URL test sample that passes through this modifier will be examined to see if it "matches" any of the links or forms extracted from the immediately previous response. It would then replace the values in the URL test sample with appropriate values from the matching link or form. Perl-type regular expressions are used to find matches.

    Control Panel

     

    Matches are performed using protocol, host, path and parameter names. The target sampler cannot contain parameters that are not in the response links.

     

    Spidering Example

    Consider a simple example: let's say you wanted JMeter to "spider" through your site, hitting link after link parsed from the HTML returned from your server (this is not actually the most useful thing to do, but it serves as a good example). You would create a Simple Controller , and add the "HTML Link Parser" to it. Then, create an HTTP Request, and set the domain to ".*", and the path likewise. This will cause your test sample to match with any link found on the returned pages. If you wanted to restrict the spidering to a particular domain, then change the domain value to the one you want. Then, only links to that domain will be followed.

    Poll Example

    A more useful example: given a web polling application, you might have a page with several poll options as radio buttons for the user to select. Let's say the values of the poll options are very dynamic - maybe user generated. If you wanted JMeter to test the poll, you could either create test samples with hardcoded values chosen, or you could let the HTML Link Parser parse the form, and insert a random poll option into your URL test sample. To do this, follow the above example, except, when configuring your Web Test controller's URL options, be sure to choose "POST" as the method. Put in hard-coded values for the domain, path, and any additional form parameters. Then, for the actual radio button parameter, put in the name (let's say it's called "poll_choice"), and then ".*" for the value of that parameter. When the modifier examines this URL test sample, it will find that it "matches" the poll form (and it shouldn't match any other form, given that you've specified all the other aspects of the URL test sample), and it will replace your form parameters with the matching parameters from the form. Since the regular expression ".*" will match with anything, the modifier will probably have a list of radio buttons to choose from. It will choose at random, and replace the value in your URL test sample. Each time through the test, a new random value will be chosen.

     


    Figure 18 - Online Poll Example

     

     

    One important thing to remember is that you must create a test sample immediately prior that will return an HTML page with the links and forms that are relevant to your dynamic test sample.


    18.7.9 JDBC PreProcessor

    The JDBC PreProcessor enables you to run some SQL statement just before a sample runs. This can be useful if your JDBC Sample requires some data to be in DataBase and you cannot compute this in a setup Thread group. For details, see JDBC Request .

    See the following Test plan:

    See Also:

     

    In the linked test plan,"Create Price Cut-Off" JDBC PreProcessor calls a stored procedure to create a Price Cut-Off in Database, this one will be used by "Calculate Price cut off".

     


    Create Price Cut-Off Preprocessor

     

     

    18.4.14 User Defined Variables

    The User Defined Variables element lets you define an initial set of variables , just as in the Test Plan . Note that all the UDV elements in a test plan - no matter where they are - are processed at the start. So you cannot reference variables which are defined as part of a test run, e.g. in a Post-Processor.

    UDVs should not be used with functions that generate different results each time they are called. Only the result of the first function call will be saved in the variable. However, UDVs can be used with functions such as __P(), for example:

    HOST      ${__P(host,localhost)}   
    which would define the variable "HOST" to have the value of the JMeter property "host", defaulting to "localhost" if not defined.

     

    For defining variables during a test run, see User Parameters . UDVs are processed in the order they appear in the Plan, from top to bottom.

    For simplicity, it is suggested that UDVs are placed only at the start of a Thread Group (or perhaps under the Test Plan itself).

    Once the Test Plan and all UDVs have been processed, the resulting set of variables is copied to each thread to provide the initial set of variables.

    If a runtime element such as a User Parameters Pre-Processor or Regular Expression Extractor defines a variable with the same name as one of the UDV variables, then this will replace the initial value, and all other test elements in the thread will see the updated value.

    Control Panel

     

    If you have more than one Thread Group, make sure you use different names for different values, as UDVs are shared between Thread Groups. Also, the variables are not available for use until after the element has been processed, so you cannot reference variables that are defined in the same element. You can reference variables defined in earlier UDVs or on the Test Plan.

     

    Parameters

    AttributeDescriptionRequired
    NameDescriptive name for this element that is shown in the tree.No
    User Defined VariablesVariable name/value pairs. The string under the "Name" column is what you'll need to place inside the brackets in ${...} constructs to use the variables later on. The whole ${...} will then be replaced by the string in the "Value" column.No

     


    18.7.5 User Parameters

    Allows the user to specify values for User Variables specific to individual threads.

    User Variables can also be specified in the Test Plan but not specific to individual threads. This panel allows you to specify a series of values for any User Variable. For each thread, the variable will be assigned one of the values from the series in sequence. If there are more threads than values, the values get re-used. For example, this can be used to assign a distinct user id to be used by each thread. User variables can be referenced in any field of any jMeter Component.

    The variable is specified by clicking the Add Variable button in the bottom of the panel and filling in the Variable name in the 'Name:' column. To add a new value to the series, click the 'Add User' button and fill in the desired value in the newly added column.

    Values can be accessed in any test component in the same thread group, using the function syntax : ${variable}.

    See also the CSV Data Set Config element, which is more suitable for large numbers of parameters

    Control Panel

    Parameters

    AttributeDescriptionRequired
    NameDescriptive name for this element that is shown in the tree.No
    Update Once Per IterationA flag to indicate whether the User Paramters element should update its variables only once per iteration. if you embed functions into the UP, then you may need greater control over how often the values of the variables are updated. Keep this box checked to ensure the values are updated each time through the UP's parent controller. Uncheck the box, and the UP will update the parameters for every sample request made within its scope .Yes

     


    posted on 2014-03-04 11:19 順其自然EVO 閱讀(6384) 評論(0)  編輯  收藏 所屬分類: jmeter

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    統計

    常用鏈接

    留言簿(55)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲伦理中文字幕| 久久久久国产免费| 精品国产综合成人亚洲区| 四虎最新永久免费视频| 国产AV日韩A∨亚洲AV电影 | 国产免费久久精品| 99免费在线视频| 亚洲性无码AV中文字幕| 亚洲精品少妇30p| 妞干网在线免费观看| A级毛片高清免费视频在线播放| 亚洲三级视频在线观看| 国产L精品国产亚洲区久久| 国产成人福利免费视频| 国产免费黄色无码视频| 亚洲最大无码中文字幕| 人人狠狠综合久久亚洲婷婷| 国产视频精品免费| 99免费观看视频| 一个人看www免费高清字幕| 亚洲日本国产综合高清| 亚洲AV无码专区在线播放中文| 免费黄色毛片视频| **aaaaa毛片免费同男同女| 国产大片免费天天看| 亚洲国产成人久久精品软件| 91大神亚洲影视在线| 亚洲午夜久久久久久久久电影网 | 亚洲色精品VR一区区三区| 亚洲国产一二三精品无码| 国产成人涩涩涩视频在线观看免费 | 日本免费人成网ww555在线| 久久精品亚洲日本波多野结衣| 久久精品国产亚洲av麻豆色欲 | 毛色毛片免费观看| 波多野结衣免费一区视频| 日韩一级片免费观看| 亚洲精品无码国产片| 亚洲乱码一区av春药高潮| 国产亚洲人成网站观看| 亚洲精品乱码久久久久久蜜桃|