A Complete Overview of VuGen Script Recording Options in LoadRunner:
A Brief Introduction on VuGen Scripting was given in our earlier tutorial in this Step by Step LoadRunner Guide.
In this tutorial, we will discuss some of the important ‘Recording Options’.
‘Recording Options’ is one of the important concepts in script recording. It allows various options for selection on how the script is to be recorded.
=> Click Here For Complete Series of LoadRunner Tutorials
Table of Contents:
Options in Script Recording
As seen in the previous tutorial, we can see ‘Recording Options’ link on the left bottom corner of the ‘Start Recording’ page.
Click on this link to open the ‘Recording Options’ page.
Let us discuss these options in detail now:
#1) General-Recording
This option allows us to select one of the two recording options:
- HTML based
- URL based
(i) HTML based: HTML based recording is also called as context-sensitive (or context based) recording. In this mode of recording, each user action is recorded as a separate request. For Example, when a user performs an action (example login), one ‘login request’ is created.
In the Example below, we have the Vugen script recorded in the HTML mode for invoking the url and logging into the ‘Web tours’ application.
Here there are two user actions – Invoke url and Login. Thus two requests are recorded, one for each of these user actions.
// Request1 – Invoke Web Tours url
web_url("index.htm", "URL=http://127.0.0.1:1080/WebTours/index.htm", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=../favicon.ico", "Referer=", ENDITEM, "Url=https://www.bing.com/favicon.ico", "Referer=", ENDITEM, LAST);
// Request2 – Login
web_submit_form("login.pl", "Snapshot=t2.inf", ITEMDATA, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=login.x", "Value=47", ENDITEM, "Name=login.y", "Value=10", ENDITEM, LAST);
Also, if we see, the first request shows the url but the second doesn’t. Which means the second request (Login) is dependent on the response of the previous request (invoke url) and hence this mode of recording is called the ‘Context-sensitive’ recording.
The advantage of HTML based recording is that the scripts are smaller and simple and do not require much customization/enhancements (correlation etc.).
The flipside is that the maintenance of the scripts may become difficult – the requests being context sensitive, any UI change would impact the script and may lead to errors on replay.
An HTML based recording is generally recommended for browser-based applications.
(ii) URL based: URL based recording is also called as context-insensitive or contextless recording. In this mode of recording, each request to the server (initiated by a user action) is recorded as a separate request with the url.
For Example, when a user performs an action (E.g. login to an application), along with the main login HTML page, non-html resources like the images, javascript, CSS files etc. are also downloaded. URL based recording generates requests for each of these requests separately.
In the Example below, we have the Vugen script recorded in the URL mode for launching the url and logging into the ‘Web tours’ application.
Here again, there are two user actions – Invoke url and Login, But there are more than two requests as the images and icons associated with the ‘Invoke url’ action are recorded as separate requests.
// Request1 – Invoke Web Tours url
web_url("index.htm", "URL=http://127.0.0.1:1080/WebTours/index.htm", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTTP", LAST); web_concurrent_start(NULL); // Request1a - image web_url("hp_logo.png", "URL=http://127.0.0.1:1080/WebTours/images/hp_logo.png", "Resource=1", "RecContentType=image/png", "Referer=http://127.0.0.1:1080/WebTours/header.html", "Snapshot=t3.inf", LAST); // Request1b - image web_url("webtours.png", "URL=http://127.0.0.1:1080/WebTours/images/webtours.png", "Resource=1", "RecContentType=image/png", "Referer=http://127.0.0.1:1080/WebTours/header.html", "Snapshot=t4.inf", LAST); web_concurrent_end(NULL); web_concurrent_start(NULL); // Request1c - icon web_url("favicon.ico", "URL=http://127.0.0.1:1080/favicon.ico", "Resource=1", "Referer=", "Snapshot=t9.inf", LAST); // Request1d - icon web_url("favicon.ico_2", "URL=https://www.bing.com/favicon.ico", "Resource=1", "RecContentType=image/x-icon", "Referer=", "Snapshot=t10.inf", LAST); web_concurrent_end(NULL);
// Request2 – Login
web_submit_data("login.pl", "Action=http://127.0.0.1:1080/cgi-bin/login.pl", "Method=POST", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home", "Snapshot=t12.inf", "Mode=HTTP", ITEMDATA, "Name=userSession", "Value=123203.335763467zDDHcHVpfiDDDDDDDiAc", ENDITEM, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, "Name=login.x", "Value=47", ENDITEM, "Name=login.y", "Value=10", ENDITEM, LAST);
If we see, all the requests have their respective URLs. Which means the requests are not dependent on the response of the previous request, hence this mode of recording is called ‘Context-less’ recording.
Scripts generated in the URL based recording are large and complex, hence they require more customization/enhancements (correlation etc.).
However, the maintenance of the scripts is easy, as the requests are being contextless, any UI change would not impact the script.
An URL based recording is generally recommended for non-browser (Windows) based applications.
In the HTML mode, there is a second option ‘A script containing explicit URLs only’ which combines the advantages of both (HTML and URL modes of recording) – the script remains small and simple, hence the maintenance of the scripts becomes easy. This mode of recording is mostly recommended for Web Applications.
#2) General-Script
We generally do not change any of these options, but it is worth understanding at least some of them.
Language: This drop-down allows us to select the language to use when working with the script. The allowed language(s) is dependent on the protocol used. For Web-http/HTML protocol, ‘C Language’ and ‘JavaScript’ languages are supported. And we shall select ‘C Language’ here.
Property – Generate think time greater than the threshold: This option directs VuGen to insert think time (wait time between user actions) only if the user waits for a value more than the threshold (3 sec here) mentioned.
Other properties are self-explanatory.
#3) General-Protocols
This option shows the protocol(s) that was/were selected to record the script. We can select-deselect accordingly.
#4) HTTP Properties-Advanced
This page offers various options to help customize the code generation and replay.
Let’s understand some of these options.
Reset context for each action – This option resets all HTTP contexts between actions so that the Vuser more accurately emulates a new user by beginning a browsing session. This option ensures that a context-less function is always recorded at the beginning of the action. It also clears the cache and resets the usernames and passwords.
Save snapshot resources locally – This option saves a local copy of the snapshot resources during record and replay. This helps in creating snapshots more accurately and displaying them quicker.
The other options can be left to default.
#5) Network – Mapping and Filtering
This allows us to select one of the 3 Capture levels:
- Socket level
- WinINet level
- Socket level and WinINet level
In Socket level recording, the native Socket API developed by Micro Focus (for Loadrunner) is used to interact with (and record the requests/traffic) the various application-level protocols like HTTP, FTP etc. Port mapping is relevant here.
In the WinINet level recording, the WinINet API developed by Microsoft (for Windows) is used to interact with (and record the requests/traffic) the various application-level protocols at a specified port (port mapping is not relevant here).
If we select WinINet level, LoadRunner records traffic that is generated by the application which uses the WinINet API to communicate to the servers. If we select Socket level, Vugen captures the traffic on the socket-level at a specified port.
It is not an easy answer to say which one of these to select when recording the script. It is better to use trial and error method – if the script is not recorded, switch between these options until we succeed.
As explained above, for socket-level capture, Port mapping is relevant and is used to map the traffic from a specified server-port combination to the desired communication protocol (traffic filtering is used to exclude the traffic from a specified server-port).
Also, the ‘Options’ button takes us the Advanced Port Mapping settings which allow us to select the SSL versions etc. but most of the times we do not worry about these options.
So far, we discussed the recording options that are relevant for script recording. We will cover the other recording options in our subsequent tutorials.
UPDATE:
Below are the hands-on video tutorials recorded on the Micro Focus LoadRunner version but still very relevant and useful on Micro Focus LoadRunner version as well.
VIDEO 1 – VuGen Recording Options Part I
This video tutorial will give an overview of VUGen Script and Protocol Recording Options in detail.
Video 1 Summary:
This tutorial covers the VuGen Recording Options. Apart from this, it also covers:
- Script Section
- New Virtual User dialog
- Start Recording dialog
In Script Section, we discussed three sections of the script (vuser_init, Action, vuser_end) and running sequence.
On New Virtual User Dialog, we try to touch base with all the fields and their importance so that while selecting the protocol for scripting, user should know its significance. This is the first step for script creation. VuGen provides option to create Single Protocol and Multiple Protocol script.
On Start Recording Dialog, we discussed the fields with their valid input data. This is second step for script creation. From this dialog type of application, browser, URL, working directory, and “Record into Action” options are selected.
In Recording Option, we covered the following topics in detail:
- Scripts
- Protocol
- Recording
- Port Mapping
- Advanced Settings
- Correlation
- Code Generation
Script – This provides option to select the scripting language along with few settings related to the script. For Web (HTTP/HTML) protocol, the scripting language is C.
Protocol – This displays the protocol that we selected on New Virtual User Dialog box.
In the part-1, we have seen script sections and different dialog. For Recording options, we have seen how to select scripting language and confirm the protocol that is going to be used while scripting.
We will see the remaining Recording options in part 2 below.
VIDEO 2 – VUGen Recording Options Part 2
This video tutorial covers the most important recording options like Recording, Port Mapping, Advanced Settings, Correlation, Code Generation in detail with examples.
Video 2 Summary:
This tutorial covers the remaining Recording options. In part-1 we have seen Script and Protocol. The other options are:
- Recording – Selection of mode or http/html level can be done from this. We discussed in detail URL and HTMl mode of web (HTTP/HTML) protocol, which gives good understanding and idea about the major difference between them.
- Port Mapping– This provides option for Port Mapping.
- Advanced Settings– This covers few advanced settings related to script generation or script execution. We discussed each option available in detail.
- Correlation– This is related to Automated Correlation. Correlation rules are created and enabled from this. In short, we discussed the fields available for the users on this dialog.
- Code Generation– This enhance the data format capabilities of web protocol.
The part I and II tutorials explain all important fields on different dialog boxes related to recording options and protocol selection which user should know before using LoadRunner. This will make you ready for recording a script with all the required information for VuGen configuration.
Conclusion
In this tutorial, we discussed the ‘Recording options’ (options that are relevant for recording the script).
We shall discuss ‘Recording options part 2’ when we discuss ‘Correlation’ in our upcoming tutorial of the series.
=> Visit Here For Complete Series of LoadRunner Tutorials