lr_xml_find function example
In this lr_xml_find function example you will learn how to use lr_xml_find in LoadRunner Vugen script.The lr_xml_find function verifies that whether XML values return by the server which will contains a specified query or not,simply lr_xml_find verifies the XML values with the help of XML Query.
Also READ:
Create a Script for REST API
Create GOAL Oriented Scenario
lr_xml_find function example
Syntax
lr_xml_find(List of specifications ,List of optional specifications , LAST);
List of Specifications
For the following list of required specifications, use the following string format:
lr_xml_find(“XML=response”,
“Query=return/msg”,
“Value=success”,LAST);
Query: the XML Query or The Fast Query on the input XML string.
XML: the XML Input String to perform a query.
Choose one of the following:
Example of lr_xml_find
Here I am using CreateFlight order SOAP request to find the XML response and verifying the response data as per given response.
WebService Script
CreateFlightOrder Request
web_service_call( “StepName=CreateFlightOrder_101”,
“SOAPMethod=HPFlights_Service|FlightsServiceMethods|CreateFlightOrder”,
“ResponseParam=response”,
“Service=HPFlights_Service”,
BEGIN_ARGUMENTS,
“ExpectedResponse=SoapResult”,
“Snapshot=t1476592590.inf”,
“xml:FlightOrder=”
“<CustomerName>Sujith Kumar</CustomerName>”
“<FlightOrder>”
“<Class>EconomyEconomy</Class>”
“<DepartureDate>2016-10-18</DepartureDate>”
END_ARGUMENTS,
“<FlightNumber>1089</FlightNumber>”
“<NumberOfTickets>1</NumberOfTickets>”
“</FlightOrder>”,
BEGIN_RESULT,
LAST);
“CreateFlightOrderResult/OrderNumber=Param_OrderNumber”,
“CreateFlightOrderResult/TotalPrice=Param_TotalPrice”,
END_RESULT,
Actual 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>18</OrderNumber>
<TotalPrice>196</TotalPrice>
</CreateFlightOrderResult>
</CreateFlightOrderResponse>
</s:Body>
</s:Envelope>
In above response we are going to verify OrderNumber is created or not as below.
Action()
{
web_service_call( “StepName=CreateFlightOrder_101”,
“SOAPMethod=HPFlights_Service|FlightsServiceMethods|CreateFlightOrder”,
“ResponseParam=response”,
“Service=HPFlights_Service”,
BEGIN_ARGUMENTS,
“ExpectedResponse=SoapResult”,
“Snapshot=t1476592590.inf”,
“xml:FlightOrder=”
“<CustomerName>Sujith Kumar</CustomerName>”
“<FlightOrder>”
“<Class>EconomyEconomy</Class>”
“<DepartureDate>2016-10-18</DepartureDate>”
END_ARGUMENTS,
“<FlightNumber>1089</FlightNumber>”
“<NumberOfTickets>1</NumberOfTickets>”
“</FlightOrder>”,
BEGIN_RESULT,
LAST);
“CreateFlightOrderResult/OrderNumber=Param_OrderNumber”,
“CreateFlightOrderResult/TotalPrice=Param_TotalPrice”,
END_RESULT,
lr_xml_find(“XML={CreateFlightOrder_101_Response}”,
“Query=CreateFlightOrderResult/TotalPrice”,
“Value=196”,LAST);
return 0;
}
![]() |
Script Reply Summary |
![]() |
Script Reply Log |
Please let me ask you a dought regarding text virification we have to give static text for verification right? otherwise if we run with some othe data it wont work? one dought is my response is not only html tags it is comming mixing of someother . is there any way to setup to get in tags format only?
Please help me in webservice scripting how to down load file?