Local Data Driven Test

Let's create a new, Local Data Driven test. We'll go through five iterations of the test, each with a different search text.

  1. Create a new Web Test and click Record.
  2. Navigate to www.google.com, enter Telerik in the Google search box, and hit the Search button.
  3. Click the Pause button in the docked IE toolbar.
  4.  

    Recording Bar

     

  5. Click the Local Data button in the bottom of the test or the Data tab in Visual Studio.
  6.  

    Local Data Button

    Standalone version

    VS Local Data Button

    VS plugin

     

  7. There are three buttons at the top of this pane. Only Create a new data table is enabled. Click it to add a new grid for data.
  8.  

    Add Data

     

  9. The default grid will have five columns. This example will execute five iterations of the test with different search text for each.
  10. Change the columns text box to 1 and click Update.
  11.  

    Update columns

     

  12. Enter any text into the first grid cell and hit the Enter or Tab key. The input will move to the second row.
  13. Continue entering text for the remaining grid cells. New rows are added as you type.
  14.  

    Add Columns

     

  15. Right click Col1 and choose Rename Column. In this example, Numbers is the new name.
  16.  

     

  17. Save the test.
  18. Data from an array can be used in recorded steps and code behind methods. To bind data from a data array to a recorded step, continue step 13. To use reference data from the data array in a code behind method, skip to step 22.
  19. Click the Test Steps at the button of the test or the Step tab in Visual Studio to return to the Test Steps View
  20.  

    Test Step Button

    Standalone version

    VS Steps Button

    VS plugin

     

  21. Highlight step 2. This is the recorded step that sets the value of the Google search text box.
  22.  

    Select Step

     

  23. The properties for this step appear in the Properties pane, located on the right of the screen.
  24.  

    Step Properties

     

  25. Click the '...' button for (Bindings).
  26. Choose the 'Numbers' from the drop down for Text.

    Select column

  27. Click the Set button.

    Set Button

  28. The data for the column named Numbers from the data array is now bound to the Text property for that step. Instead of entering Telerik into the search box, the data stored in the array will be entered.
  29. Save and execute the test. Note that the test will execute for each row in the data array, for a total of five iterations.
  30. To use reference data from the data array in a code behind method, follow these steps.
  31. Highlight step 2. This is the recorded step that sets the value of the Google search text box. Right click the step and select Customize Step in Code.
  32. Choose Visual Basic or C#.
  33. Use the Data property followed by the index of the column to reference data from the grid. For example:

    1. C#

    2. //Reference a column by name
    3. Pages.Bing.SbFormQText.Text = Data["Numbers"].ToString();
    4.   
    5. //Reference a column by index (zero based)
    6. Pages.Bing.SbFormQText.Text = Data[0].ToString();

    1. Visual Basic

    2. 'Reference a column by name
    3. Pages.Bing.SbFormQText.Text = Data("Numbers").ToString()
    4.  
    5. 'Reference a column by index (zero based)
    6. Pages.Bing.SbFormQText.Text = Data(0).ToString()
  34. Save and build project.
  35. Execute your test. Note that the test will be executed for each row in the data array.
     
  36. Note: If the test executes too quickly to validate visually, click the Enable Annotation button and set the delay in milliseconds before executing. These are located in the Record/Execute ribbon.

     

    Annotation

    Standalone version

    VS Annotation

    VS plugin