LoadRunner Learning---scripting (4) (more important)

Source: Internet
Author: User

Today, we'll go on to translate http://www.wilsonmar.com/in the LoadRunner Scripting section, the following are some of the more important parts of the translation script.

Web user Action

In Vugen, the default pattern generated by the script is HTML-based-the "script that describes the user's action" directly corresponds to the user's action:

* Web_url is the URL of the browser address bar.

* Web_link is a text hyperlink that is clicked between <a href= ...> and <a>.

* Web_image is click on the HTML

* Web_submit_form is the "commit" point on the Get or put form in the context of the previous operation-the previous action may have been vugen in HTML-based mode.

* Web_submit_data is the point "commit" on a get or put form without a context with the previous action-probably recorded in a URL-based mode, or in HTML mode, and "a scr& #299;p t containing is selected. Explicit URLs only "option.

The resources that are generated without HTML are. gif and. jpg pictures. The list of resource properties can only be inserted when the direct option for these resources is set to "Record within the current scr& #299;p t Step". This is also the default setting.

If you select "a scr& #299;p t containing explicit URLs only" in Tools > Internet procotol > Recording, This will result in url-based script recording, using only the Web_url and Web_submit_data functions, will not use Web_link and web_image functions, or contained in applets, XML, ActiveX or JAVASCR & #299 Non-HTML elements in;p T.

Before you make the next page recording (such as clicking a link or icon), pause the recording, copy the title of the page's screen and paste it into the note. After the recording is complete, this will be used in the subsequent naming of the transaction.

After each page is displayed, pause the recording to copy the text of the desired page and paste it into the comment. Once the recording is complete, this will be used in scripting of the text verification checkpoint.

The various information generated in the recording is saved in the RecordingLog.txt file, and deleting it does not affect the playback of the script.

Extra-Recorded action script

When recording a script, the following lines of code are captured when the browser does not have an SSL root certificate installed. This message means "This certificate cannot be authenticated by a trusted certificate".

Web_url ("Authrootseq.txt",


"Url=http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootseq.txt",
Xat1a/kj0 "Resource=1",
U$~3mwpp;@e/v0 "Reccontenttype=text/plain",
T~sy:jw0 "Referer=",
7g{) BE5JF}0last), 51Testing Software Test Network} ' E @ w*b. ' Cs1o S

Web_url ("Authrootstl.cab",


"Url=http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authrootstl.cab", 51Testing Software Test Network ' [email protected]+ea9z6e8m
"Resource=1",
lt2o*h$} ~zr0 "Reccontenttype=application/octet-stream", 51Testing software test mesh Z ' U] ' {-DPW
"Referer=", 51Testing Software Test network/vb ' Guwjp,s
last);
When you record a script, but the browser encounters the Macromedia Flash component, the following line of code is generated:

"Url=http://fpdownload.macromedia.com/pub/flashplayer/update/current/xml/version_en_win_ax.xml",
#r3rJbr (_0 "resource=0",
"P0x6~ q.i0" reccontenttype=text/html ",
| (C?FC P i2f2] ' S0 "referer=", 51Testing software test network b I}WJ v8~
"Snapshot=t8.inf",
0v! E g#k o) q#xk5d#?0 "mode=html",
Sz "Pi%oth" bz0z0last);
Web_url ("Version_en_win_ax.xml",
If you have Google Toolbar installed, you'll record a request to Google even if you don't have access to Google.
Scripting language Rules:
In LoadRunner, casing is sensitive, even in the values being tested. Therefore, the above script will not recognize "Welcome" because of the capital letter. So Steve Cheney recommends using "IC" to ignore case-sensitive text flags:
Web_reg_find ("Text/ic=welcome", last);
The arguments in parentheses contain last to specify a final argument. This is convenient because the example above misses a property that specifies whether the expectation is "found" or "NotFound". The default is "found", all I often ignore it.
Another text flag is "/bin" to specify the character set that is binary. For example, find "Adams":
Web_reg_find ("text/bin=\\x00a\\x00d\\x00a\\x00m\\x00s", last);
Note Two backslashes, one is an escape character, and a symbol is used. If the error only uses a backslash, LR will consider it to be an empty termination.
The following example script is supported on the UTF8 server to obtain NEWQUOTEUID for UTF-16 encoding. Because LoadRunner, UTF16 encoded "Red" is r\x00e\x00d\x00 with ASCII, so it needs to be saved to buffer.
Lr_eval_string_ext ("{newquoteuid_temp}",
L*by,o#t:kw}/j]0 strlen ("{newquoteuid_temp}") + 2,
Q r9z?-\5q:g0 &buf, &buflen, 0, 0,-1);
For the character array variable newbuf use the Lr_save_var function to remove the extra padding (x00):
for (i=0; I if (buf[i]!=0) newbuf[newbuflen++]=buf[i];51testing Software test network 5os9pr-]4v~ Y
Lr_save_var (newbuf, NewBufLen-1, 0, "Newquoteuid");
Note: Lr_save_var requires four parameters (does not need to use last)
1.param_value parameter values
2 The length of the Value_len parameter.
3 options for option parameters, typically 0
4. Param_name parameter name
LoadRunner 7.8 does not support regular expressions, but has his own wildcard character:
In order to make any number [0-9] in the specified number position, use/dig to make the mark:
Web_reg_save_param ("Pser", "Lb/dig=serial xxx-###-zzzz", "rb=\r\n", last);
There are three ways to use the ^ to do wildcard characters:
* Ignores case, and allows any character to be used at the specified character position:
web_reg_find ("Text/alnumic=^ercury", last);
* Allow any lowercase characters [a-z] at the specified location:
web_reg_find ("Text/alnumlc=^ercury", last);
* Allow any uppercase characters [A-z] at the specified character position:
  Web_reg_find ("Text/alnumuc=^ercury", last);
to turn a string into uppercase:STRUPR ()
error message:
Please add some other error messages to help others:

Could not resolve address of host ... [msgid:merr-27798]
Displays a 404 DNS error if the network is not available or if the domain is not registered


Contents unexpectedly not in cache. [msgid:merr-26549]

This error is displayed when a file is empty. Add a space to the empty file to satisfy the LoadRunner error check. BTW, because when an IFRAME is created without a file, IE generates an error so that an empty file is specified.

Transaction time Script writing:

I prefer to give an action a name transaction instead of a result page.


Lr_start_transaction ("00.1 Invoke URL");
[Email Protected]&zl m8x{0 ...
(ET) japf.n8}q0lr_end_transaction ("00.1 Invoke URL", Lr_auto);
A3d&b*vw5~0 ...
L9l4g]}m/j bd9i0lr_start_transaction ("01.2 Top menu"); 51Testing Software Test Network B%hu (v2q]k[
...
B6{efsn#x4u (~0lr_end_transaction ("01.2 Top menu", Lr_auto); 51Testing Software Test Network him{~9m*l
51Testing Software Test Network +c (Vy4mp&eod
Lr_start_transaction ("02.0 Updating");
2j$va!y ' U0lr_start_sub_transaction ("02.1 Update menu", "02.0 Updating"); 51Testing Software Test Network: F (I!xj*o P:az
Web_url (... 51Testing Software Test Network Eeq RXX!B{%F.G (}[email protected]/j
Lr_end_sub_transaction ("02.1 Update menu", Lr_auto);
7ukq! Sdpnnp1l-e}0lr_start_sub_transaction ("02.2 Update submit", "02.0 Updating"); 51Testing Software Test network [4bbn7d1b! '%e
Web_submit_form (...
p$y| [Mxfb0lr_end_sub_transaction ("02.2 Update submit", Lr_auto);
t {n-|+e m\s ' t) h0lr_start_sub_transaction ("02.3 Update OK", "02.0 Updating");
c9~u{%} ^0web_url (...
! W;gv+x_5r0lr_end_sub_transaction ("02.3 Update OK", Lr_auto);
' U; ' @{/s0
9~i h:hd%[email protected]_end_transaction ("02.0 Updating", Lr_auto);

I like to use a 0 filled transaction name in a hierarchy so that the controller can sort the transactions correctly.

I add a different keyword to the transaction name on different types of action

Contact link = Click ' Contact ' link on Menu
Contact icon = Click the "Contact" icon
Regis. Sub = Page Submit
OK = pop-up dismiss with OK

The transaction name can be a variable, but it is compiled only by Vugen as a string and cannot be displayed in the interface of the controller. In any case, they will appear in the analysis results file.

For web scripts, LR automatically creates and determines the duration of the transaction, but the C script can use these functions:

Use the Lr_start_transaction_instance function to explicitly obtain a handle to the specified transaction instance, the transaction name in the function lr_user_data_point_instance or lr_user_data_point_instance Used in _EX.

Use Lr_start_sub_transaction to manipulate think time and time spent in a transaction.

Well, the scripting part of the basic has been translated half, it's time to go to sleep, the following will continue to translate checkpoints, manipulating strings, getting data from the stream, parameterization, how to use files, associations, collection points, etc., the content is still a lot of.

LoadRunner Learning---scripting (4) (more important)

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.