Use of _javaScript jmeter __substring functions and functions do nested string variable parameter passing taken

I. Description:

        A man of business scenario is that, after a single case goods, will generate an order number, after eight random code when paying only need the order number, and this time it is necessary for the incoming dynamic order number string interception, so as to pay for success, if only tested once can be obtained manually, but you need to perform many times you need to get moving.

Second, the implementation steps

   1, the first is the need to communicate, completely understand business scenarios that help to expand the interface testing, or foggy mess the whole no practical significance.

    2, according to the script and sort of business scenarios offered, combined with the current bottlenecks encountered: A interface to generate a single order number [each] are dynamic order number, when B interface payment, only need to pass the A interface Order No. 8 after random code; that is, the a interface 8 to get the random number as a reference when the B interface transmission request, generates order number and the 49 order 8-bit and 8 bits a interface consistent with the order number.

    2.1 The following figures: the generated order number, you need to use regular expressions to extract the order number, a reference to the next request.

 2.2 The following figures use regular expressions to extract the order number

 

 

 

3, the start of a dynamic interception order number, need to use

    __javaScript: javaScript function to execute some JavaScript (! not Java) code and returns its value [translation] from the official website

    __substring: Take the string string.

     Expression will be understood that the figures are: the use __substring incoming dynamic function interception order number, starting from the brackets 36 characters, 44 characters to the second end, __javaScript function returns successfully intercepted data as a parameter passing; $ {tradeNo} variable reference] [order number, with reference to step 2.2.

 

 

 

4, below shows the results after the success.

 

 

Guess you like

Origin www.cnblogs.com/dxw-dong/p/11778344.html