Sunday 25 August 2019

How to download and install Gatling tool | Gatling tool for Performance testing

Gatling is a highly capable load testing tool. It is designed for ease of use, maintainability and high performance.It is the best developer tool to load test your web applications.

Gatling comes with excellent support of the HTTP protocol that makes it a tool of choice for load testing any HTTP server. As the core engine is actually protocol agnostic, it is perfectly possible to implement support for other protocols.
Gatling’s architecture is asynchronous as long as the underlying protocol, such as HTTP, can be implemented in a non blocking way. This kind of architecture lets us implement virtual users as messages instead of dedicated threads, making them very resource cheap. Thus, running thousands of concurrent virtual users is not an issue.

How to download Gatling:

Click here to go download link and select click on open source version and click on download and once it is done extract the folder and place on C drive.

How to capture all HTTP Responses in load runner

If you want to capture the http response of a page, but some times it may redirects as HTTP 301,HTTP 302 etc

By using the below code we can capture the status code and write itin to a variable.

HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);

You need to place it after all the page request in the script. However, this will only capture the LAST status code received. If there is a redirection in between, it will not be captured. So to capture that we need to use web_reg_save_param function with the following arguments.

Use "ORD=ALL" argument to capture all occurrences and 
use "Search=Headers" argument to search the response header only

web_reg_save_param("HttpResponses","LB=HTTP/1.1 ", "RB= ", "Search=Headers" ,"ORD=ALL", LAST);


The HttpResponse variable contains all http requests and output log as a message.

PSR Tool | Windows Problem Steps Recorder (PSR)

Problem steps recorder (PSR) is a tool that is available in Windows since Windows 7 (client) / Windows 2008 R2. It's a built-in Windows tool that allows to screen-capture on mouse-click and add comments to it. So it's an ideal tool to document steps and procedures on the fly, while you're executing. Although it's a very handy tool and quick and easy to use, one of the disadvantages is that it does not capture keystrokes.

Here is the process how to use it:

1. In Windows 7, go to start menu and type "psr"
2. When psr.exe shown up on menu, click on it to open
3. This will open the PSR tool window as shown in below



4. Click on the drop down and click settings and provide output location 





5. Set the screen capture to 100 (max) and press OK button

6. Click on Start Record button and start your flow

7. If you want add any comments click on Add Comments and write your comments.



8. Once you are done with you flow press Stop Record button. A window will open for saving the session.

9. You can attach this file to your defect.

10. This zip file will have all the screenshot with labels of each and every activity that was done.

Removing leading zero from the date in LoadRunner - 06/12/2020 to 6/12/2020

How to change 06/12/2020 to 6/12/2020? here is the code..

Action()
{
char month[10],day[10],year[10],startingDate[10]; //Declaration the variables here
int nonzeroday, nonzeromonth;

strcpy(startingDate,"");

lr_save_datetime("Today's Date is: %m/%d/%Y",DATE_NOW,"normal_date"); //Capturing Today's date and writing it to the Log

lr_output_message(lr_eval_string("{normal_date}"));

lr_save_datetime("%m",DATE_NOW,"month"); //Capturing month of date to a parameter
lr_save_datetime("%d",DATE_NOW,"day");  //Capturing day of date to a parameter
lr_save_datetime("%Y",DATE_NOW,"year");//Capturing year of date to a parameter

nonzeromonth=atoi(lr_eval_string("{month}")); // This it to remove zero from the month value
lr_save_int(nonzeromonth,"month");

nonzeroday=atoi(lr_eval_string("{day}"));  // This it to remove zero from the day value
lr_save_int(nonzeroday,"day");


strcat(startingDate,lr_eval_string("{month}")); //Concatenating  date with '/' to create a date
strcat(startingDate,"/");
strcat(startingDate,lr_eval_string("{day}"));
strcat(startingDate,"/");
strcat(startingDate,lr_eval_string("{year}"));


lr_save_string(startingDate,"p_startingDate");
lr_output_message("Corrected Date is: %s", lr_eval_string("{p_startingDate}"));

return 0;
}

Then your final output will be:

Action.c(34): Today's Date is: 06/12/2020
Action.c(65): Corrected Date is: 6/12/2020

Script to generate random order number and pass to html element

Here is the sample script  to generate random order number and pass to html element:

<script>
function randomOrder(length, chars)
{
var string = '';
for (var i=length; i > 0; --i)
string += chars[Math.round(Math.random() * (chars.length - 1))];
return string;
}
var orderNum = randomOrder(7, '0123456789'); 
document.getElementById("order_num").innerHTML = "ORDER #GMO" +orderNum;
</script>