Association in JMeter (regular expression +json)-Empty Valley Orchids

Source: Internet
Author: User

1. What is Association?

The associated dynamic change value returned by the server is saved as a parameter for subsequent interfaces to use;

2. Correlation method in JMeter

(1) Regular expressions

We will now use the regular expression to take the ID 1, and then as the next request to enter the parameter;

notation for regular Expressions: "id": (. *), "age": 18

The next request entry is: ${id}, look at the return result

Successful access to ID 1

With common meta characters:

Code description
. Match any character other than line break
\w match letters or numbers or underscores or kanji
\s matches any whitespace character
\d Matching numbers
\b Match the beginning or end of a word
^ Start of matching line
$ match end of line

Commonly used anti-literal metacharacters
Code description
\w matches any characters that are not letters, numbers, underscores, kanji
\s matches any character that is not a white letter
\d matches any non-numeric character
\b Match is not where the word starts or ends
[^x] matches any character except X
[^aeiou] matches any character except the letters AEIOU


Common repeating qualifiers
Code description
* Repeat 0 or more times
+ Repeat one or more times
? Repeat 0 or one time
{n} repeats n times
{n,} repeats n or more times
{N,m} repeats n to M times

(2) JSON path Extractor plugin

Note: JMeter 3.0 can install this plug-in, 2.0 version can install the plug-in, but does not take effect, so want to use the plugin or install 3.0 version and above the JMeter;

JMeter official has a plugin for the JSON path extractor: http://jmeter-plugins.org/wiki/JSONPathExtractor/

Click on the download below, there are n multiple versions of the selection, here we choose 2.6 version

2.6 version of the download after the success of the compressed package

Download after successful decompression;

Then put the jpgc-json-2.6 under the Lib folder Jmeter-plugins-cmn-jmeter-0.3.jar under the JMeter installation address under the Lib folder

Then put the downloaded Lib-ext two files under the JMeter installation path under the Lib-ext

JMeter Getting Started with plugins

Simple example:

Complex examples:

DRIVER_SWITCH_SCHEDULE_ID in the data this list, take the first driver_switch_schedule_id, that will first take the value inside the result, and then take the data inside, The first element in data is then taken.

$.result.data[0].driver_switch_schedule_id

Association in JMeter (regular expression +json)-Empty Valley Orchids

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.