LoadRunner learning knowledge-checkpoint

Source: Internet
Author: User

LRCheckpoint

The purpose of setting checkpoints is not only to verify that our scripts are correct, but also to make the test results more convincing, therefore, we recommend that you add checkpoint settings in all test scripts.

 

 I. How to set checkpoints

1. Switch the script to the tree structure, find the text you want to check on the page view page, right-click the script, and select Add a text check.

2. Switch the script backCodePage, manually add the following code when the cursor is flashing up

Web_reg_find ("text = payment details", "savecount = para_count", last );

Here is the page script to run

If (atoi (lr_eval_string ("{para_count}")> 0) // verify whether the string to be checked is found on the page

Lr_output_message ("pass! ");

Else

Lr_output_message ("failed! ");

Note:

L "payment details" indicates the text you want to check;

L The script is executed here. No matter whether the string you want to check exists on the page, the script will not report an error, but will be executed.

L this code saves the number of strings you want to check as a parameter. Then, after the Page code, check whether the value of this parameter is greater than 0 to determine whether the string you want to check is found.

L The test results here are all returned with a 200 status code. The failure results are classified in the analysis report.

// The Role Of The atoi () function is to convert an ASCII string to an integer.

// The lr_eval_string () function is used to obtain the parameter value, replace the parameter value in the string variable with the current parameter value, and return this string

 

3. The cursor stays at the position of the function to be inserted. In the Insert menu, select new step, select or search for the function to be inserted in the list, and fill in necessary parameters as prompted;

 

2. Pay attention to setting check points

1. when using checkpoints, we also need to pay attention to some issues. Generally, we need to set some Chinese checkpoints, but LR is not supported by default. If you set a Chinese checkpoint and report an error, then you should pay attentionSelect the set UTF-8 when recording the script, As shown in:

2. When using text check points,Enable image and text check points, As shown in:

This option is not checked by default.

 

Iii. Errors frequently occurring during the running of the checkpoint script

1. Error code error-27257: Pending web_reg_save_param/reg_find/create_html_param [_ ex] request (s) detected and reset at the end of iteration number 1

Cause: the position of web_reg_find is incorrect. You put it at the end of an action, and it is followed by return 0, so an error occurs.

Solution: The web_reg_find location is incorrect and should be placed in front of the Request page.

 

2. Error code: Action. C (27): Error-26366: "text = ABC" not found for web_reg_find [msgid: MERR-26366]

When this problem occurs, check whether web_reg_find is placed before the content to be searched.

 

3. Error code: Action. C (22): Error-27191: "web_image_check" failed (0 occurrence (s) found. [msgid: MERR-27191]

 

If it is web_find (), check whether the function is behind the content to be searched; if it is web_image_check (), view the imageSource codeTo see if it is an image on this page, it is likely that the image is incorrect, that is, the selected image does not belong to this page.

 

 

Iv. Related functions

1.Web_find ()Function

Web find ("web_find", "righof = A", "leftof = B", "What = Name", last );

Parameter explanation: "web_find" defines the name of the search function; "leftof" and "righof =" are used to define the left and right boundary of the search character; "What =" defines the search content;

For example, in the preceding parameter example, find the information with the left boundary B, right boundary A, and content name on the page;

Note: This function is used to find the content on the page, so it should be placed behind the content to be searched. This function can only be searched in HTML-based recording scripts.

 

2.Web_reg_find ()Function

Web_reg_find ("Search = body", "savecount = DDD", "test = aaa", last );

Parameter description: search is used to define the search range. savecount defines the name of the search count variable. This parameter can be used to record the number of times the search content appears in the cache, to determine whether the content to be searched is found;

For example, the preceding parameter example indicates that the body searches for information with AAA content and records the number of occurrences in the variable DDD;

Notes for using this function: This function is used to find the corresponding content in the cache, so it should be placed before the search content. It is usually written before the following six functions: web_castom_request (); web_image (); web_link (); web_submit_data (); web_submit_form (); web_url ();

TIPS: there is a "savecount" in the parameter of this function. This parameter can be used to record the number of times the content appears in the cache, to determine whether the content to be searched is found.

 

3.Web_image_check ()Function

Web_image_check ("web_image_check", "alt =", "src =", last );

Parameter explanation: the values of ALT and SRC take the values of the corresponding parameters of the image in the source code of the webpage;

After testing, this function uses the front or back of the search content without affecting the search results.

 

V. Comparison between web_find and web_reg_find Functions

    • L these two function types are different. web_find is a common function and web_reg_find is a registered function;
    • L content check must be enabled when using web_find, while web_reg_find does not;
    • L web_find can only be used in HTML-based recording scripts, but web_reg_find does not have this restriction;
    • L web_find searches for content on the returned page, while web_reg_find searches for content in the cache;
    • L web_find is less efficient than web_reg_find in execution;
    • L web_find is used after the check content, while web_reg_find is used before the check content.

 

Under what circumstances will checkpoints be used?
1. Verify if the login is successful
2. Verify that the page Jump is correct

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.