Assign data to API test steps - Tutorial
Relevant for: API testing only
This tutorial teaches you how to assign data to your test steps. The test steps are based on the sample Flight API application provided with UFT One.
Note: For the task related to this scenario, see Assign data to API test/component steps.
Prerequisite - import the Web Service methods
For this scenario, you use the GetFlights and CreateFlights methods from the sample Flight API application.
To import the service:
-
Open the Flight API application from the Start menu or screen or the file system (<UFT One installation folder\samples\Flights Application\Flights API.exe).
-
Copy the URL for the Web Service of the Flight API Application.
-
Import the Web Service into UFT One.
Associate a data source with your test
Add the sample application Excel data source to your test. This file (SampleAppData.xlsx) is found in the <UFT One installation>\samples\Flights Application directory.
-
In the Data pane, click the New Data Source button and select Excel.
-
In the New/Change Excel Data Source Dialog Box, navigate to sample application Excel file. Click OK to add the Excel file to the test.
The data source is displayed in the Data pane.
Create your test steps
From the Toolbox pane, drag the following steps to the canvas in order:
-
GetFlights (found in the Local Activities > Web Services node)
-
CreateFlightOrder (found in the Local Activities > Web Services node)
-
Report Message (found in the Miscellaneous node)
Manually enter the input properties for the GetFlights step
To provide property values for the GetFlights step, use the first method for providing data by manually entering the property values.
To provide the property values:
-
In the canvas, make sure that the GetFlights step is selected.
-
In the Properties pane, open the Input/Checkpoints tab .
-
In the Input/Checkpoints tab, manually select the following values from the property value drop-down lists:
-
DepartureCity: Denver
-
Arrival City: Los Angeles
-
Link the CreateFlightOrder input properties to the data source
When the GetFlights method runs in the Flight API application, it automatically creates a number of output properties, including the airline number, price, and a flight number.
In this step, you link the input property values of the CreateFlightOrder step both to the output of the GetFlights step and to the sample Excel file you associated with your test.
-
In the canvas, select the CreateFlightOrder step.
-
In the Properties pane, open the Input/Checkpoints tab .
-
In the Input/Checkpoints tab, in the Value cell for the FlightNumber input property, select the Link to data source button .
-
In the Select Link Source Dialog Box (API Testing), link the FlightNumber property to the GetFlights step output property of the same name. When prompted if you would like to link the selected property as part of a loop, select No.
For details on linking to another test step property, see Link your test step to another step.
Note: By default, the FlightNumber property is not visible. Expand the GetFlightsResult node and click the Add button to expand all the output properties.
-
In the Input/Checkpoints tab, link the remaining input properties to the relevant columns in the Excel data source.
Note: Make sure to clear the NIL property on any property values.
Link the Report step input properties to the CreateFlightOrder step
For the final step of this tutorial, you will create a custom expression to mimic the Flight API application's passing of flight data to a flight booking Web site page. For this, create the custom message that the results display.
-
In the canvas, select the Report Message step.
-
In the Properties pane, open the Input/Checkpoints tab .
-
In the Input/Checkpoints tab, in the Value cell of the Message property, select the Link to data source button .
-
In the Select Link Source Dialog Box (API Testing), click the Custom Expression button to display the expression area.
-
In the expression area, enter the text "Your flight order number is (with an extra space at the end).
-
In the Select Link Source Dialog Box (API Testing), select the Available step option.
-
In the list of available steps (left pane), select the CreateFlightOrder step.
-
In CreateFlightOrder properties list in the right pane, in the Output Properties section, expand the CreateFlightOrderResult node.
-
In the output properties list, select the OrderNumber property.
-
Click Add to add this to the custom expression.
-
Click OK in the Select Link Source dialog box to add this expression.
-
The following expression appears in the Value column of the Message property:
Your flight order number is {Step.OutputProperties.StServiceCallActivity4.Body.CreateFlightOrderResponse.CreateFlightOrderResult.OrderNumber}
View the run results
Run the test. When the run results open, explore the nodes in the Test Flowtree and check the results of your steps in step summary.
In the captured data for the CreateFlight step and the Report Message step, you should see the data values passed between steps.