Test a GUI application with output values

Output value steps capture a specific step result, which can then be used as parameter values in a subsequent step.

This exercise describes how to add and run a test with an output value.

Create a new test for output values

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

To create the test:

  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 MyFlightOutputVal, and then click Save.

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

Tip: To display all 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 a SEARCH ORDER action

The MyFlight GUI sample app has a second tab for the SEARCH ORDER page, which enables you to search for previous flights reserved.

Add a new action to the end of your test to perform steps in the SEARCH ORDER tab.

To add the FlightOrderSearch action:

  1. In the Solution Explorer, right-click the MyFlightOuputVal test, and select Add > Call to New Action.

  2. In the Name field, enter FlightOrderSearch.

    Ensure that the At the end of the test option is selected, and then click OK to add the new FlightOrderSearch action to the end of your test.

    For example:

  3. Create an object repository for the SEARCH ORDER page. Open and log in to the MyFlights GUI app, and click the SEARCH ORDER tab at the top left.

    For more details, see Flight GUI layer.

  4. Select Resources > Object Repository Manager.

    Use the Navigate and Learn process to learn all the objects on the page, as you did earlier in this tutorial.

    Save the new object repository in the same folder as the others: C:%HOMEPATH%\My Documents\UFT One\Tutorial_Object Repositories. Name the object repository Search.

    For more details, see Create object repositories.

  5. In the MyFlights app, replace the NAME value with Mary Sanchez, and click SEARCH.

    A list of all the flights you've reserved for Mary is listed on the SELECT ORDER page.

  6. In UFT One, open the Object Repository Manager window again, and learn all of the objects on the SELECT ORDER page.

    Save the new object repository in the same location as the other repositories, and name it SearchResults.

  7. Associate the new object repositories with the FlightOrderSearch action. For more details, see Create object repositories.
  8. Open the FlightOrderSearch action, and add steps to search for your flight orders.

    In the Editor, copy and paste the following lines of code:

    Copy code
    WpfWindow("OpenText MyFlight Sample").WpfTabStrip("WpfTabStrip").Select "SEARCH ORDER"
    WpfWindow("OpenText MyFlight Sample").WpfEdit("byNameWatermark").Set "Mary Sanchez"
    WpfWindow("OpenText MyFlight Sample").WpfButton("SEARCH").Click
    WpfWindow("OpenText MyFlight Sample").WpfTable("ordersDataGrid").SelectCell 1, 1
    WpfWindow("OpenText MyFlight Sample").WpfButton("SELECT ORDER").Click
  9. Continue with Add an output value step.

Back to top

Add an output value step

Add an output value step to the FlightConfirmation action to capture the passengerName value. You'll use this later on as a parameter value in the FlightOrderSearch action.

To add an output value step:

  1. In the MyFlight GUI app, log in, search for, and reserve a flight, until you get to the FLIGHT DETAILS page. This is the page where you enter the passenger name. Leave the Passenger Name field blank.
  2. In UFT One, in the MyFlightOuputVal test, open the FlightConfirmation action in the Keyword View.
  3. Right-click the passengerName step, and select Insert Output Value.
  4. In the Output Value Properties dialog that appears, in the Name field, enter OutputPassengerName.
  5. In the object properties grid, scroll through the properties and select the text property row. Note that there is no value provided for this property.

  6. Below the properties grid, click Modify.

  7. In the Output Options dialog, define where to store the step output value.

    • Ensure that the DataTable parameter type and the Global sheet are options are selected.
    • In the Name field, enter passengerName_text.

  8. Click OK to return to the Output Value Properties dialog.

    • Notice that the text value has been updated with the <passengerName_text> output value.
    • Select the After current step option on the bottom, and then click OK.

    UFT One adds an output step after the passengerName Set step.

    In the Editor, the steps look like this:

    Copy code
    WpfWindow("OpenText MyFlight Sample").WpfEdit("passengerName").Set "Mary Sanchez"
    WpfWindow("OpenText MyFlight Sample").WpfEdit("passengerName").Output CheckPoint("OutputPassengerName")
    WpfWindow("OpenText MyFlight Sample").WpfButton("ORDER").Click
    WpfWindow("OpenText MyFlight Sample").WpfButton("NEW SEARCH").Click

    The passengerName_text column is also added to the Global data table below.

  9. Continue with Use your stored output value.

Back to top

Use your stored output value

Add parameters to the FlightOrderSearch action, to use the stored output value you just created.

To use the output value in a parameter:

  1. Open the FlightOrderSearch action in the Keyword view.

  2. Select the byNameWatermark step, and in the Value column, click the parameterization button.

  3. Select the DataTable tab, double-click the passengerName item, and press ENTER to parameterize this step.

    The step now reflects that the value is provided by a parameter.

    In the Editor, the new step has the following syntax:

    WpfWindow("OpenText MyFlight Sample").WpfEdit("byNameWatermark").Set DataTable("passengerName_text", dtGlobalSheet)
  4. Save your test, and continue with Run the test with an output value.

Back to top

Run the test with an output value

Run the MyFlightOutputVal test to view how UFT One uses the passenger name value provided as a parameter name in a subsequent action.

To run the test:

  1. Close all MyFlights app windows before you start running the test.
  2. In UFT One, select Record > Record and Run Settings.

  3. In the Windows Applications tab, select Record and Run only on.

    The FlightsGUI.exe app details are saved there from previous runs.

  4. Click OK to close the dialog and return to UFT One.

  5. For the purposes of this tutorial, you only need to run one iteration of this test.

    1. In the Solution Explorer, right-click the MyFlightOutputVal test, and select Settings.
    2. Click Run, and select to Run on one iteration only.
    3. Click Apply and then OK to return to UFT One.
  6. Save your test, and then click Run.

    In the Run dialog, ensure that the MyFlightOutputVal test name and the New run results folder are selected.

    Click Run to run the test.

  7. When the test run completes, drill down in the Test Flow to the FlightConfirmation node and the Standard Output: "OutputPassengerName" step. A summary of the output value details is shown on the right.

  8. Scroll further down in the Test Flow to the FlightOrderSearch node and the byName.Set step. The step summary shows the step result, including the value used for the Set operation during runtime.

    This value should show the value set in the FlightConfirmation action.

Back to top

Next steps: