Showing posts with label Loadrunner Effort Estimation. Show all posts
Showing posts with label Loadrunner Effort Estimation. Show all posts

lr_xml_extract example

lr_xml_extract function extract particular value or total XML details from a String,lr_xml_extract example provides complete real time examples to work with different load testing scripts in your real time projects.

Loadrunner Articles: LR_XML_FIND function Examples

What is lr_xml_extract?


lr_xml_extract function extract or retrieve the value from a XML which could be input parameters or it could be XML response/Results.We can say this function extract the XML pieces you can say particular data from a String.In this post i am taking SOAP web-services example to extract value from a XML why because web services are designed in the form of XML form.

Syntax


lr_xml_extract([<XML input string>] ,[<XML Parameter>] ,[<XML Query>],[LAST]);

Example:


lr_xml_extract("XML={CreateFlightOrder_101}","XMLFragmentParam=Result","Query=CreateFlightOrderResult/TotalPrice",LAST)

1.XML Input String: It is the string indicates from which XML fragments results or input parameters should take or identify.
Example : XML={CreateFlightOrder_101}

2.XML parameters: In this specifications we are going to save the results as per Query i.e XMLFragmentParam=Result,Here i am saving XML query results into Result parameter and displaying those string values with the help of lr_output_message function.

3.XML Query : It is very important to write the query for XML fragment whether this could be for Input parameter or it could be for XML response.You can write XML Query as per your requirement ,most of the time we are writing the query in order to verify the value in XML Response to validate the same.
Example : Query=CreateFlightOrderResult/TotalPrice

4.LAST : lAST it is giving two results one is if Query is satisfied then it will give you the results as PASS from LR_PASS and in case XML Query is not satisfied then it will give you results as FAIL from LR_FAIL.

lr_xml_extract example


Please understand below example ,here i am using Web Services Scripting,in case you want to learn Web Services Scripting please read my article.Let's see the below example.

Create Flight Order Request:


Below are the SOAP Web Services XML Requests and Response.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hp="HP.SOAQ.SampleApp">
<soapenv:Header/>
<soapenv:Body>
<hp:CreateFlightOrder>
<hp:FlightOrder>
<hp:Class>Economy</hp:Class>
<hp:CustomerName>Rajesh Kuchana</hp:CustomerName>
<hp:DepartureDate>2016-12-17</hp:DepartureDate>
<hp:FlightNumber>1089</hp:FlightNumber>
<hp:NumberOfTickets>1</hp:NumberOfTickets>
</hp:FlightOrder>
</hp:CreateFlightOrder>
</soapenv:Body>
</soapenv:Envelope>

Create Flight Order Response


<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateFlightOrderResponse xmlns="HP.SOAQ.SampleApp">
<CreateFlightOrderResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<OrderNumber>50</OrderNumber>
<TotalPrice>196</TotalPrice>
</CreateFlightOrderResult>
</CreateFlightOrderResponse>
</s:Body>
</s:Envelope>

Now if you want to extract <TotalPrice>196</TotalPrice> then you can write XML Query as below
Query=CreateFlightOrderResult/TotalPrice

CreateFlightOrderResult : Starting opening tag under this tag TotalPrice value is displaying
TotalPrice : This is the value we want to extract from XML response.

You can write for other value i.e <OrderNumber>50</OrderNumber>
Query=CreateFlightOrderResult/OrderNumber

Then it will print the results as <OrderNumber>50</OrderNumber>

Loadrunner Web-Services Script:


I have recorded this script with the help of WebServices protocols and as per above XML Query path prepared lr_xml_extract function.
Action()
{
lr_start_transaction("01_CreateFlightOrder");
web_service_call("StepName=CreateFlightOrder_101",
"SOAPMethod=HPFlights_Service|FlightsServiceMethods|CreateFlightOrder",
"ResponseParam=response",
"Service=HPFlights_Service",
"ExpectedResponse=SoapResult",
"Snapshot=t1477884670.inf",
BEGIN_ARGUMENTS,
"xml:FlightOrder="
"<FlightOrder>"
"<Class>Economy</Class>"
"<CustomerName>Rajesh Kuchana</CustomerName>"
"<DepartureDate>2016-12-17</DepartureDate>"
"<FlightNumber>1089</FlightNumber>"
"<NumberOfTickets>1</NumberOfTickets>"
"</FlightOrder>",
END_ARGUMENTS,
BEGIN_RESULT,
"CreateFlightOrderResult/OrderNumber=Param_OrderNumber",
"CreateFlightOrderResult/TotalPrice=Param_TotalPrice",
END_RESULT,
LAST);

//Extract the value using lr_xml_extract function
lr_xml_extract("XML={CreateFlightOrder_101_Response}",
"Query=CreateFlightOrderResult/TotalPrice","XMLFragmentParam=Result",LAST);

//Print the Results with the help of lr_output_message() function
lr_output_message(lr_eval_string("Extracted Value is :-{Result}"));

lr_end_transaction("01_CreateFlightOrder",LR_AUTO);

return 0;
}

Once you run above script VuGen displays all your each and every step details in ReplyLog and XML Response,lr_xml_extract function results as below.

Output:


Action.c(4): Notify: Saving Parameter "CreateFlightOrder_101_Response = <CreateFlightOrder><CreateFlightOrderResult><OrderNumber>54</OrderNumber><TotalPrice>196</TotalPrice></CreateFlightOrderResult></CreateFlightOrder>".
Action.c(4): Notify: Saving Parameter "response = <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><CreateFlightOrderResponse xmlns="HP.SOAQ.SampleApp"><CreateFlightOrderResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OrderNumber>54</OrderNumber><TotalPrice>196</TotalPrice></CreateFlightOrderResult></CreateFlightOrderResponse></s:Body></s:Envelope>".
Action.c(4): Notify: Saving Parameter "Param_OrderNumber = 54".
Action.c(4): Notify: Saving Parameter "Param_TotalPrice = 196".
Action.c(4): Web service call "CreateFlightOrder_101" was successful
Action.c(30): Notify: Parameter Substitution: parameter "CreateFlightOrder_101_Response" = "<CreateFlightOrder><CreateFlightOrderResult><OrderNumber>54</OrderNumber><TotalPrice>196</TotalPrice></CreateFlightOrderResult></CreateFlightOrder>"
Action.c(30): Notify: Saving Parameter "Result = <TotalPrice>196</TotalPrice>".
Action.c(30): "lr_xml_extract" succeeded, 1 match processed
Action.c(32): Notify: Parameter Substitution: parameter "Result" = "<TotalPrice>196</TotalPrice>"
Action.c(32): Extracted Value is :-<TotalPrice>196</TotalPrice>
Action.c(34): Notify: Transaction "01_CreateFlightOrder" ended with "Pass" status (Duration: 1.8496 Wasted Time: 0.3214).

[caption id="attachment_995" align="aligncenter" width="569"]Reply Summary Reply Summary[/caption]

What have you Learned?


1.What is lr_xml_extract function
2.lr_xml_extract example
3.How to extract value using lr_xml_extract
4.How to print output message using lr_output_message.

Please provide your valuable comments on this post and as well as provide your suggestions,in case you like my post please share it to different social networking sites.

Effort Estimation template for performance testing

Welcome to Loadrunner ,in this Effort Estimation template for performance testing you will learn how to create Load/Performance testing Effort Estimation for different Business scenarios.Actually what is Effort Esstimation in Software Testing,Effort Estimation nothing but testing plan for particular project or component as per available number of Employes and number of testing hours/days required to complete the testing.Let's discuss or learn with real time examples.

Effort Estimation template for performance testing


Performance Testing Effort Estimation template have different points to consider before preparing the estimation for your project or applications or Business process,some of the major factors are

1.Business process Scenario
2.What are the major projects are available right now
3.How much Employe/Resources can afford on this project(In case handling Multiple projects)
4.What are the transaction steps involved

Test Estimation Effort Template


Test Estimate Template contains different fields as below

1.Doc Ref.No
2.Business Process
3.Performance Script
4.Performance Script Details
5.No of Hours(Resource-based)

Doc Reference No


Doc Reference Number refers business process FSD or BRD or Business NFR doc number like 1.2,1.3 etc.So here it could be Doc 1.2

Business Process


Business process means one scenario like Send an email from Gmail application.In this business scenario you can find number of steps to perform to complete one transaction as below

1.Open Gmail
2.Login with valid credentials
3.It will display inbox,
4.Click Compose
5.Enter To address,cc,Subject
6.Enter Mail Body
7.Attachments etc
8.Click on Send



As per above step's you have to identify how much time it will take to create the script in Vugen.

Performance Script Details


Performance Scrip details have different various point as below

1.Vuser Script Recording - To Record scripts in Virtual User Generator for a Business Process.
2.Vuser Script Validation - Validate the script with Conditions , prepare Correlation and add functions.
3.Performance Script Enhancements - Preparing Test data for execution , Runtime Settings,Replacing dynamic values with Correlated values , Saving the values into parameter and Parameterization in the script.
4.Vuser Script Execution - Execution of Business process Script in VUGen to verify the script.
5.Loadrunner Controller Scenario - Preparing real world mimic scenario for prepared Business process Script as below details.
1.Number of virtual users to use.
2.Number of virtual users to initiate with how many seconds.
3.Number of Hours to Run the script.
4.How to stop the VUsers at a time or slowly means 2 or 5 or 6 etc.
6.Scenario Execution - After creating or preparing the scenario in Controller run your scenario by starting the Load Generator in order to verify how many transactions are pass/fail or contains errors while running the scripts.
7.Analysis Reports - Analyze the reports with the help of Analysis component in Loadrunner to check what are the bottlenecks,how many transactions are pass/fail and HTTP status code etc points you can verify in Analysis.

For each and every step should have no of hours in the testing estimation sheet as below screenshot and at last we are calculating the total hours to required to complete the Business process and send it for approval.Once approval received from respective manager then resource will start preparing Scripts for Business scenarios.

You can prepare Effort Estimation as below ,please check screen-shot.

[caption id="attachment_840" align="aligncenter" width="647"]Effort Estimation template for performance testing Effort Estimation template for performance testing[/caption]

What have you learned?


1.What is Business Process
2.What is Test Effort Estimation
3.Factors should be consider
4.Testing Estimation Template details
5.How to prepare Performance Testing Estimation based on Performance Scripts for a Business Process.

Please share this post in case you like and got good knowledge on this topic.