Creating and Storing Application Data in a Local Variable

Variables enhance tests by providing the ability to store data values for use in other parts of the script. Data can also be output to other types of files.

The sample application displays a unique email address on the Get Instant Auto Quote page. The text on this page containing the email address is the property value of a control on the page.

In this lesson, you will store this text to the local variable stremailAddr.

  1. In the script, navigate to the email value. The code should look similar to the following:
    .DomTextField("autoquoteEMail").SetText("jsmith@gmail.com")
  2. Insert the following code following the email value:
    Dim StremailAddr As String
        StremailAddr = .DomTextField("autoquoteEMail").Text
    

    This step creates a new local variable, StremailAddr, that stores the email address text from the Get Instant Auto Quote page page to the local variable.

  3. To include output that displays the variable text during playback, include a Console.Write command in your script. For example, include:
    Console.Write (StremailAddr)
  4. To view the console output, choose View > Output. The Output window opens. When you playback a script, the Output window is populated.

To confirm that the test captures the property value and stores it properly, play back the test and review the result.