Discussion on LoadRunner Character Set and checkpoint

Source: Internet
Author: User

Many people add a Chinese checkpoint to the LoadRunner test script. The check fails. Why? In fact, the conversion between the tested system and the LoadRunner Character Set fails. Let's explain it one by one.

We know that LoadRunner has a character set setting in the recording option: Recording Options> advanced> support charset. Here we can set the character set supported by LoadRunner.

So what is the relationship between the character set of the tested system and the LoadRunner character set? The following uses Baidu and Google as examples.

First, check the character set of Baidu and Google websites respectively? Open a website and right-click the source file to obtain their character set. The character set of Baidu is gb2312, And the content in the source file code is: <! Doctype HTML>

1. When recording Baidu's test script, do not set the LoadRunner character set. The script is as follows:

Action ()
{
Web_reg_find ("Search = body ",
"Savecount = Times ",
"Text = Baidu ",
Last );


Web_url ("www.baidu.com ",
"URLs = http://www.baidu.com /",
"Resource = 0 ",
"Reccontenttype = text/html ",
"Referer = ",
"Snapshot = t1.inf ",
"Mode = html ",
Extrares,
"Url =/img/i2.png", Enditem,
"Url =/img/arr.gif", Enditem,
"Url =/JS/bdsug. js? V = 1.0.3.0 ", Enditem,
"Url =/Cache/HPS/JS/hps-1.0.js", Enditem,
Last );

If (atoi (lr_eval_string ("{times}")> 0)
Lr_output_message ("search successful ");
Else
Lr_error_message ("search failed ");

Return 0;
}

Run the test script. The checkpoint can pass.

2, set LoadRunner Character Set: UTF-8, record a test script of Baidu again, the test script is the same as above. When the test script is run, the checkpoint fails and the log information displays action. C (26): Error: search failed.

Why can't checkpoints with the LoadRunner Character Set be passed without the LoadRunner character set being set to: But not the UTF-8 checkpoint? Let's take a look at the code generation information of these two scripts, which is in the codegenerationlog.txt file under the datadirectory of the test script. In this case, we can search the checkpoint "Baidu" keyword in two files. We can find the "Baidu" keyword in this file that does not set the LoadRunner character set, and set the LoadRunner character set: the UTF-8 file does not find the "Baidu" keyword. This is because setting the LoadRunner's character set to: The UTF-8 forcibly converts the information generated by the test script to the UTF-8. Therefore, for websites where the tested system character set is gb2312, the LoadRunner may fail to set the character set to: UTF-8, and the Chinese keyword as the checkpoint.

Take Google as an example:

1. Do not set the LoadRunner character set when recording a Google test script. The script is as follows:

Action ()
{
Web_reg_find ("Search = body ",
"Savecount = Times ",
"Text = map ",
Last );

Web_url ("www.google.com.hk ",
"URLs = http://www.google.com.hk /",
"Resource = 0 ",
"Reccontenttype = text/html ",
"Referer = ",
"Snapshot = t2.inf ",
"Mode = html ",
Extrares,
"Url =/extern_js/f/examples/-1wqcmgtu-m.js", Enditem,
"Url =/images/srpr/nav_logo73.png", Enditem,
"Url =/CSI? V = 3 & s = webhp & Action = & E = 17259,17315, middle, 52921 & Ei = Middle & expi = 17259,17315, 23628,28505, 28936,29561, california, California, Connecticut, 52921 & IMC = 1 & IMN = 1 & imp = 1 & RT = xjsls.47, prt.62, xjses.3922, xjsee.3953, ol.4000, iml.984, xjs.4109 ", Enditem,
"Url =/complete/search? Hl = ZH-CN & client = HP & xhr = T & Q = N & CP = 1 ", Enditem,
"Url =/complete/search? Hl = ZH-CN & client = HP & xhr = T & Q = NB & CP = 2 ", Enditem,
Last );

If (atoi (lr_eval_string ("{times}")> 0)
Lr_output_message ("search successful ");
Else
Lr_error_message ("search failed ");

Return 0;
}

Run the test script. The check point fails. The log information is displayed as action. C (31): Error: search failed.

2. Set the LoadRunner character set to: UTF-8, record a Google test script, the test script is the same as above. Run the test script and you will find that the checkpoint passes.

Why can't checkpoints that do not set LoadRunner's Character Set pass while the character set LoadRunner is: the checkpoints of the UTF-8 can pass? Let's take a look at the code generation information of these two scripts, which is in the codegenerationlog.txt file under the datadirectory of the test script. In this case, we can search for the checkpoint "map" keyword in two files. We can find that the "map" keyword cannot be found in this file without setting the LoadRunner character set, and set the LoadRunner character set: the map keyword is searchable in this file of the UTF-8. This is because the character set of LoadRunner is not set to: UTF-8, the information generated by the test script is not automatically converted to the UTF-8 but to other encode. So for websites where the character set to be tested is a UTF-8, LoadRunner must set the character set to: UTF-8, and the Chinese keywords can pass as checkpoints.

Note: after recording the script, switch to the Tree View and open the corresponding script page. The script recorded in the pageview on the right shows the Chinese version, but when switched to the server response, all the Chinese versions are replaced with garbled characters, such as "too many other characters ", the reason is that the server does not set the response encoding to gb2312.WebIn the. config file <system. Web> .... </System. Web> Add <globalization requestencoding = "gb2312" responseencoding = "gb2312" fileencoding = "gb2312"/> to the node and record the script again.

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.