In Exercise 6b: Import a Web service, you imported a WSDL file containing the details of your Web service. After you imported the service, UFT displayed the methods in the Toolbox pane. From the Toolbox pane, you can use any of these methods to create a test.
In this lesson, you will create a Web service test and parameterize it to see how Web service tests are created using the UFT API testing interface.
In the Book Flights GUI test that you created in Lesson 3: Add steps to a test, the order of the application windows was as follows:
When you create an API test of the same application, you want to make the steps match the application's flow as closely as possible. In the list of methods imported from the WSDL file, you have the following:
In order to match the flow of the user interface, you need to create API test steps that find the flight, and then create a flight order based on the customer input.
In this exercise, you will create two test steps: GetFlights and CreateFlightOrder.
Create the test steps.
- In the Toolbox pane, in the Local Activities section, expand the Web Services and then the HP_Flights Services and the FlightsServiceMethods nodes. The Toolbox pane displays the full list of available methods (six in all).
From the list of FlightsServiceMethods, drag the GetFlights method to the canvas.
A new step block is added to the canvas, called GetFlights. The Input/Checkpoints tab opens in the Properties pane.
In the Toolbox pane, from the FlightsServiceMethods node again, drag the CreateFlightOrder method to the canvas.
Link the FlightNumber property of the CreateFlightOrder step to the output of the GetFlights step.
- In the canvas, select the CreateFlightOrder step. The Input/Checkpoints tab opens in the Properties pane.
In the Input/Checkpoints tab, in the Input section, select the FlightNumber row.
- In the Value column of the FlightNumber row, click the Link to a data source button . The Select Link Source dialog box opens.
- In the Select Link Source dialog box, select the Available steps option. The Select a step: pane (left side) is updated with a list of available steps.
In the Select a step: pane, select the GetFlights step. The Select a property: pane (right side) is updated with the step properties:
- In the Select a property: pane, in the Input/Checkpoints tab , in the Output section, expand the GetFlightsResult node.
- Under the GetFlightsResult node, in the Flight (array) row, click the Add button . A new output array is added to the output properties.
- Under the Flight (array) row, expand the Flight array. A list of all the output properties for the GetFlights step is displayed.
In the list of output properties, select the FlightNumber property and click OK. When prompted if you want to enclose the target step in a loop, select No.
UFT updates the Value column for the FlightNumber property to reflect the link:
Add a data source to use in your test.
- If necessary, select View > Data to display the Data pane.
- In the Data pane, click the New Data source button and select Excel. The New Excel Data Source dialog box opens.
- In the New Data Source dialog box, in the Excel file path field, click the Browse button.
- In the Open dialog box, navigate to the application Excel file, saved in <UFT installation directory>\samples\Flights Application and click OK.
- In the New Excel Data Source dialog box, name the file WS_Flights.
- Select the Link to the Excel file in its original location option.
- Click OK to save the data source information and add the Excel data to your test.
Link the input properties of the test steps to the data source.
- In the canvas, select the GetFlights step. The Input/Checkpoints tab opens in the Properties pane.
- In the Input/Checkpoints tab, in the Input section, expand the GetFlights node.
- In the GetFlights node, select the DepartureCity row.
- In the Value column of the DepartureCity row, click the Link to a data source button . The Select Link Source dialog box opens.
- In the Select Link Souce dialog box, select the Data source column option. The list of data sources (in this case just the Excel file) is displayed in the Select a data source pane (left side).
- In the Select a data source pane, select the WS_Flights!Input node. The list of all available data parameters (columns) is displayed in the Select data pane (right side).
In the Select data pane, choose the DepartureCity column:
Click OK to link the property to this column in the data table.
UFT updates the Value column with a statement showing the link to the data source.
Repeat the process above for the step's other properties:
Repeat the same process for the CreateFlightOrder step's properties:
Note: In the Value column for this property, there is a blue box with NIL written inside. You need to click this box and remove the NIL (the box turns white) before linking the property.
Set the navigation settings for the data source.
- In the canvas, select the Test Flow (but not a step in the test flow).
- In the Properties pane, select the Data Sources tab .
- In the Data Sources tab, in the list of associated data sources, select the WS_Flights!Input entry in the table and click Edit. The Data Navigation dialog box opens.
In the Data Navigation dialog box, specify the data naviagation details:
Start at: First row Move by: 3 rows Forward End at: Last row Upon reaching the last row: Wrap around
- Click OK to assign the data navigation properties and close the dialog box.
Now that you have created a test for the flight reservation application's Web service, you can run the test and see how UFT runs and reports run results for the Web service. Continue with Exercise 6d: Run a Web service test to learn more.