JMeter using BeanShell for correlation

Source: Internet
Author: User

The so-called Association, how many number is through the corresponding information to crawl part of the information, such as hidden or session .

to use correlation in jmeter, divide it into 2 steps:

Step 1. in the Sampler Request Add regular expression, get information,add > Post processors>regular expression Extractor;

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7F/52/wKioL1cZ57GyO4DkAADWuTZXjPE693.png "title=" 1.png " alt= "Wkiol1cz57gyo4dkaadwutzxjpe693.png"/>

1.1 Most of us need to intercept some of the information, you can see the source code, find the required code, and then pass regular processing, here is an example:

function is to extract the values from the usersession

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/52/wKioL1cZ6KjzOcI4AAED0wpFtnw799.png "title=" 2.png " alt= "Wkiol1cz6kjzoci4aaed0wpftnw799.png"/>

1.2 Sometimes we need to extract all the response information, and we can use the following:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/54/wKiom1cZ6BnRPu8nAAC7NjPQql0056.png "title=" 3.png " alt= "Wkiom1cz6bnrpu8naac7njpqql0056.png"/>

Step2. Add Postprocessers, select BeanShell postprocessorand proceed further.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/54/wKiom1cZ6Gayl90WAAGF-JE9Vxs329.png "title=" 4.png " alt= "Wkiom1cz6gayl90waagf-je9vxs329.png"/>


in the BeanShell We can use Java code to handle the content of the regular extract, the general step is to receive the value of the regular expression extraction, if the value needs to be used as a parameter after Sampler, we will also save it as a variable, Convenient to call later.

continue with the usersession in the first example to illustrate:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/54/wKiom1cZ6LuT4nxDAAEZnfEDm6E341.png "title=" 5.png " alt= "Wkiom1cz6lut4nxdaaeznfedm6e341.png"/>

since Post needs to be submitted in the login URL, I am saving as a variable session, the following is a call to the login URL Session value.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7F/54/wKiom1cZ6OySb0yKAAEEd7CxFyQ788.png "title=" 6.png " alt= "Wkiom1cz6oysb0ykaaeed7cxfyq788.png"/>


This article from the "Day Up" blog, reproduced please contact the author!

JMeter using BeanShell for correlation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.