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 upon 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:

  1. 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).

  2. Copy the URL for the Web Service of the Flight API Application.

  3. Import the Web Service into UFT One.

Back to top

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.

  1. In the Data pane, click the New Data Source button and select Excel.

  2. 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.

Back to top

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)

Back to top

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:

  1. In the canvas, make sure that the GetFlights step is selected.

  2. In the Properties pane, open the Input/Checkpoints tab .

  3. In the Input/Checkpoints tab, manually select the following values from the property value drop-down lists:

    • DepartureCity: Denver

    • Arrival City: Los Angeles

Back to top

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.

  1. In the canvas, select the CreateFlightOrder step.

  2. In the Properties pane, open the Input/Checkpoints tab .

  3. In the Input/Checkpoints tab, in the Value cell for the FlightNumber input property, select the Link to data source button .

  4. 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.

  5. 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.

Back to top

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.

  1. In the canvas, select the Report Message step.

  2. In the Properties pane, open the Input/Checkpoints tab .

  3. In the Input/Checkpoints tab, in the Value cell of the Message property, select the Link to data source button .

  4. In the Select Link Source Dialog Box (API Testing), click the Custom Expression button to display the expression area.

  5. In the expression area, enter the text "Your flight order number is (with an extra space at the end).

  6. In the Select Link Source Dialog Box (API Testing), select the Available step option.

  7. In the list of available steps (left pane), select the CreateFlightOrder step.

  8. In CreateFlightOrder properties list in the right pane, in the Output Properties section, expand the CreateFlightOrderResult node.

  9. In the output properties list, select the OrderNumber property.

  10. Click Add to add this to the custom expression.

  11. Click OK in the Select Link Source dialog box to add this expression.

  12. The following expression appears in the Value column of the Message property:

    Your flight order number is {Step.OutputProperties.StServiceCallActivity4.Body.CreateFlightOrderResponse.CreateFlightOrderResult.OrderNumber}

Back to top

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.

Back to top