Replacing literals with dataset references

If you have an existing test script, you can replace literal values in the script with dataset references to add realistic data to the script. You can find and replace all literals, or just the number, string, or boolean literals with a dataset reference.

About this task

You can also add a literal from a script to a dataset. If you do not use an existing dataset variable, the same literal values (the values that were captured when you recorded the test script) are used each time you run the script.

Procedure

  1. Click Script > Find Literals and Replace with Dataset Reference.
  2. Under Direction, click Forward or Backward to set the direction you want to search through a test script.
  3. Under Literal Type, set the type of literal you want to find from the following list:
    • All -- Click to find all literals in a script.
    • Numbers -- Click to find number literals in a script. A number includes integers (a whole number, not a fractional number, that can be positive, negative, or zero) or floating numbers (positive and negative decimal numbers).
    • Strings -- Click to find string literals in a script. A string stores alphanumeric values such as name, city, or state.
    • Booleans -- Click to find boolean literals in a script. Any use of the boolean literals true or false are flagged for substitution.
  4. Click Find to start the search.

    The name of the literal found in the test script appears under Literal.

  5. Click the Dataset Variable arrow to display the dataset variables and then click the dataset variable that you want the script to reference.
  6. Optionally, type a new variable name for the dataset variable you selected.
  7. Optionally, click the Add Literal to Dataset check box to add the literal value to the dataset.
  8. Click Replace to replace the literal in the script with a dataset variable reference.

    The cursor automatically moves to the next literal in the test script.

    Note: If you have a literal that is a choice in a combo box in the application-under-test, when you replace the literal with a dataset reference, you get a string data type instead of an a enumerator data type in the dataset.
  9. When you find the next literal in the test script, repeat steps 5 through 7.
  10. When finished, click Close.

    HCL OneTest UI updates the dataset with any new columns and initial values that you add in this dialog box.