Create and run an API test with standard activities

This exercise describes how to create an run an API test with standard activities that write a string to a new text file.

Create a new test

Create a new test for this exercise.

Do the following:

  1. In UFT, click New toolbar button down arrow and select New Test.

  2. In the New Test dialog box:

    1. Select API Test.
    2. In the Name field, enter Standard.
    3. Leave the default location, and leave the Solution Name field blank.
    4. Click Create to create your new test.

The test is shown in the Solution Explorer, under the Solution Untitled node, which is the default name when no solution is specified.

The empty test flow is also shown in the Document pane, in the Standard tab.

Back to top

Add steps to your test and define their properties

Add steps to your test to replace a string, create a text file, and then write the results of the string replacement to the new file.

Do the following:

  1. From the Toolbox pane, drag the following activities to the Test Flow, in this order:

    • String Manipulation > Replace String
    • File > File Create
    • File > Write to File
  2. Define properties for the Replace String step.

    Select the Replace String step in the canvas, then define the properties on the right.

    In the Input/Checkpoint tab of the Properties pane, enter the following values:

    Source string Hello world.
    Search string Hello
    Replace string Goodbye

    Note: No checkpoints are required for this step.

  3. Define properties for the File Create step.

    Select the File Create step in the canvas. Then, define the properties on the Input/Checkpoint tab as follows:

    Input area

    Define the Folder path value:

    1. Hover in the Value cell, and click the Browse for folder... button.
    2. Browse to C:\%HOMEPATH%\My Documents\Unified Functional Testing, and create a new folder named Tutorial_Files.
    3. Click OK to select the Tutorial_Files folder as the value for the Folder path.

    File name. Enter Standard Test Result.

    Overwrite. Select true.

    Checkpoints area

    Select the Result Validate checkbox.

    Leave the default value (= true).

  4. Define properties for the Write to File step.

    Select the Write to File step in the canvas. Then, define the properties on the Input/Checkpoint tab as follows:

    Input area

    Enter the following values:

    • Content. Enter Goodbye world.
    • File path. Enter C:\%HOMEPATH%\My Documents\Unified Functional Testing\Tutorial_Files\Standard Test Result

    Leave all the other default values.

    Checkpoints area

    Select the Result Validate checkbox.

    Leave the default value (= true).

  5. Save your test, and then continue with Run the test and view run results.

Back to top

Run the test and view run results

Run your test to see how UFT creates the file and writes the string to it, as configured.

Do the following:

  1. In the toolbar, click the Run button .
  2. In the Run dialog, ensure that the Standard test is selected. Accept the other default values, and click Run to start running the test.

  3. When the test run is complete and the run results are displayed, open the C:\%HOMEPATH%\My Documents\Unified Functional Testing\Tutorial_Files\Standard Test Result from the Windows Explorer.

You'll see the string Goodbye world. in the first line of the file, because UFT ran those steps using standard API activities provided by UFT.

Back to top

Next steps: