Parameterize a GUI test

In this exercise, you'll learn how to parameterize your UFT One test and run it in multiple iterations, each time with different sets of data.

Create a new test for parameterization

Create a copy of your existing MyFlight test, where you can parameterize data and then see the differences in how UFT One runs your test.

Do the following:

  1. Start with the MyFlightApplication solution open in UFT One.

    If you've closed and opened UFT One, make sure you start it with the WPF Add-in loaded.

  2. In the Solution Explorer, right-click the MyFlight test node, and select Save As.

  3. Save the test in the same location (C:\Users\<username>\Documents\UFT One).

    In the File name field, enter MyFlightParameter, and then click Save.

The Solution Explorer switches to display MyFlightParameter test instead, with all the same actions and steps as the original MyFlight test.

Tip: To display both of your tests at the same time, add the MyFlight test back to your solution.

In the Solution Explorer, right click the solution node, and select Add > Add Existing Test. Select the MyFlight test.

Back to top

Add data to your test

In the MyFlightParameter test, update the departure and arrival cities in your test to use parameter values instead of static values. This enables you to test different cities in each test run.

Do the following:

  1. In UFT One, display the Data pane. Select View > Data.

  2. Open the FlightFinder action and view it in the Keyword View.

  3. In the fromCity row, click the Value cell, and then click the parameterization button in the right side of the cell.

  4. In the popup displayed, select the DataTable tab.

    Then click + Add New Parameter at the bottom of the popup.

  5. In the Value Configuration Options dialog that opens, leave the default Parameter selection, and define the parameter name as fromCity.

    Leave the Global sheet location selected.

    Click OK to close the dialog box.

    In the Keyword View, the fromCity value is updated to use the new parameter, and the Data Table now lists Los Angeles as the first value in the fromCity column.

  6. Add more data to the fromCity parameter. In the Data table, add the following values under Los Angeles, one value per row:

    • Denver
    • Frankfurt
    • London
  7. Create a second parameter for the toCity value. This time, create the parameter directly in the Data table.

    In the Data table, click the first row in the B column and enter toCity as the new parameter name.

    Then, in the Data table toCity column, add the following values, one value per row:

    • Los Angeles
    • London
    • Frankfurt
  8. Parameterize your toCity step. In the Keyword View, double click the Value cell for the toCity step, and click the parameterization button.

    In the popup, click the DataTable tab, and then double-click the toCity parameter to insert it as the value.

    Press ENTER to complete the step.

    Your Keyword View steps and Data table should now look like this:

  9. Save your test, and continue with Run your parameterized test.

Note: To learn more about UFT data sources and data table types, see More about data sources.

Back to top

Run your parameterized test

Configure UFT One to run your test multiple times, each time with a different set of data.

Do the following:

  1. Select Record > Record and Run Settings.

  2. In the Windows Applications tab, select Record and run test on any open Windows application option and click Apply.

  3. Click OK to return to the main UFT One window.

  4. Click the MyFlightParameter test tab to display the canvas with your parameterized action.

  5. Do the following to add two new actions to your test, to open and close the MyFlights sample app between test iterations.

    Right-click and select Insert Call to New Action. Name the new actions OpenApp and CloseApp.

  6. Select and drag the OpenApp action to the top of the test.

  7. Open the OpenApp action in the Editor, and add the following command to close any leftover processes from previous runs:

    SystemUtil.closeProcessByName("FlightsGUI.exe")
  8. Use the Step Generator to add the FlightsGUI application. Alternatively, in the Editor, add the following step to the OpenApp action:

    SystemUtil.Run "C:\Program Files (x86)\Micro Focus\UFT One\samples\Flights Application\FlightsGUI.exe"
  9. Open the CloseApp action in the Editor, and add the following step:

    SystemUtil.closeProcessByName("FlightsGUI.exe")
  10. Select File > Settings > Run node to open the Settings dialog.

  11. In the Data Table iterations section, select Run on all data rows. This ensures that UFT One runs a test iteration for each row in the Global data sheet.

    Close the dialog box.

  12. Check to see if you need to update.
  13. Run your test. Click Run.

    In the Run dialog box:

    • Ensure that MyFlightParameter is selected as the Test Name.
    • On the Results Location tab, select New run results folder.
    • Accept all other defaults.

    Click OK to run your test. The run results open when the test run is complete.

Back to top

Analyze run results

This time, your run results display four different nodes, one for each test iteration. These correspond to the four different data rows in the Global data table.

Expand the FlightFinder action nodes for each iteration. Click the fromCity.Select or toCity.Select steps to view step details for each iteration.

Back to top

More about data sources

UFT One enables you to add parameter values using the following data sources:

  • Global data tables. Data sheets containing parameters and values available to all actions in the test.

    The test runs as many times as there are data rows in the data sheet. This is the option used in this exercise.

  • Action data tables. Data sheets containing parameters and values available only to the associated action.

    The action itself will run as many times as there are data rows in the data sheet, within a single test iteration.

  • Environment variables. A variable set in your test with a fixed value.

  • Random number. A random number generated by UFT One in the test run.

For more details, see Parameterize object values and Value configuration and parameterization.

Back to top

Next steps: