Automation Testing101 : Load Runner

·

6 min read

What is LoadRunner

  • LoadRunner is a software testing tool from Micro Focus. It is used to test applications, measuring system behaviour and performance under load.
  • LoadRunner can simulate thousands of users concurrently using application software, recording and later analyzing the performance of key components of the application

LoadRunner Architecture

Screenshot (283).png

  • There are 3 main components in loadrunner.
  • VuGen (Virtual User Generator) : It is used for scripting. capturing browser/any other application traffic using VuGen. This is nothing but a test script. It has extension as .USR
  • Controller : We push all our test script to controller so that it can execute with specified amount time and specified number of user load with the help of load agents/generators. All load agents which are responsible for apply load on Application under test were configured in controller. Our test script which are In controller are called scenarios, they have an extension of .LRS. We can connect any number of load agents to controller.
  • Analysis : Once the controller executed the test scenarios, it generates an output file with an extension of .LRR. LRR is nothing Load Runner Results. Analyzer will help us interpret results generated by controller in an awsome graphs/reports. Analyzer will save its files with an extnesion of LRA.

More about VuGen.

  • When you install loadrunner you should be able to get all the above components.
  • When you create a new VuGen script it takes C:\Users\Administrator\Documents\VuGen\Scripts\ as its default location. It also create 3 files vuser_init, Action and vuser_end
  • When we record a script we have select a file, so that all our script will be saved to that perticular file, we can call this script as an action file where we have all our recorded script.
  • In Single loadrunner VuGen script we may have any number of action files if we add transactions start and end code snippets, loadrunner consider them as a test case. when you replay it will show you whether that transaction/testcase is pass/fail. Agai in single action file we may have any number of transactions.
  • Since virtual user component based on c language, it generates global.h where it imports all needed libraries for our script.
  • In our default created files, we also have runtime setting and parameters under extra files which will be used when we run our script.
  • As mentioned this component helps us to create script, VuGen has an option where it automation creates script based on recording. before start of recording we need to specify options like which action we can use to add the script, where to record(browser/windows app etc), if it is browser then url etc,
  • Once you start recording, it generate script of each action you perform on web, we will have options to comment script for every action we do, pause, save and abort script recording etc.
  • Before you start recording we are not browser, we are not supposed to open any other instance of that browser, as loadrunner may confuse on which instance traffic need to be captured. We should also wait till the browser gets loaded completed to avoid other important steps while recording.

Top functions we use in VuGen Scripts

  • lr_start_transaction : The lr_start_transaction function marks the beginning of a transaction. To indicate a transaction to be analyzed, use the lr_start_transaction and lr_end_transaction functions. These functions are inserted immediately before and after the transaction. lr_start_transaction can be nested. we can consider this as start of test case.
  • web_reg_save_param_ex : registers a request to find and save dynamic data within the server response to the next action function. The data to be saved is between the specified left and right boundaries. The search does not to apply values returned as a result of calls to asynchronous or cross-step functions. We have static and dynamic parameters, static params we pass through parameters file in VuGen, Dynamic parameters we handle through this function.

  • web_url: The web_url function is an action function that loads the Web page (GET request) specified by the URL argument. (Each Web Action Function in a script causes the browser to display a new Web page or frame. All Web Action functions can be recorded by VuGen.) The web_url function does not require a context.

  • web_revert_auto_header : The web_revert_auto_header function is a service function that stops adding a specific user–defined header to subsequent HTTP requests. This function cancels the automatic header generation for the specified header, initiated by web_add_auto_header. It continues to generate Implicit Headers, as if no web_add_auto_header or web_remove_auto_header function was ever issued.
  • web_submit_data : The web_submit_data function is an action function that performs an "unconditional" or "contextless" form submission. (Each Web Action Function in a script causes the browser to display a new Web page or frame. All Web Action functions can be recorded by VuGen.) This function allows you to generate GET and POST requests as made by the HTML forms. You do not need to have a form context to execute this request.
  • web_custom_request: The web_custom_request function is an action function that allows you to create a custom HTTP request using any method or body. VuGen generates this function only for requests that cannot be interpreted with other web functions.

  • lr_think_time : lr_think_time allows you to pause test execution during a run. This is especially useful in simulating think time, the time a real user pauses to think between actions.

  • web_reg_find: The web_reg_find function registers a request to search for a text string on a Web page retrieved by the next action function. The search does not apply to values returned as a result of calls to asynchronous or cross-step functions.


Parametrization in VuGen:

  • Once you done with recording a script, you may need to parametrize few of the properties like url of the website, username and password etc. To achieve this we have parameters file which will be created by default, we just need to add our parameters into this file.
  • every parameter that we add here will be saved in .data file, you can also select single .data file if they are related, ex: username and password. Here the file will be having two columns instead of single column. Once you have created the parameter you can you simply update this parameter name in an enclosed curtly brackets, like {parameter_name} so that its value will be replaced while script is getting executed.

What is Correlation in LoadRunner

  • Correlation is the capturing of dynamic values passed from the server to the client and back. We save this captured value into a LoadRunner parameter, and then use this parameter in the script in place of the original value.

References

Helping Testers