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.

    pause

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

    Standalone
    Standalone Version
    VS Plugin
    VS Plugin
  5. 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.

    fig4

  6. The default grid will have five columns. This example will execute five iterations of the test with different search text for each.

  7. Change the columns text box to 1 and click Update.

    fig5

  8. Enter any text into the first grid cell and hit the Enter or Tab key. The input will move to the second row.

  9. Continue entering text for the remaining grid cells. New rows are added as you type.

    fig6

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

    fig7

  11. Save the test.

  12. 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.

  13. Click the Test Steps at the button of the test or the Step tab in Visual Studio to return to the Test Steps View

  14. Standalone
    Standalone Version
    VS Plugin
    VS Plugin
  15. Highlight step 2. This is the recorded step that sets the value of the Google search text box.

    fig10

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

    fig11

  17. Click the '...' button for (Bindings).

  18. Choose the 'Numbers' from the drop down for Text.

    fig12

  19. Click the Set button.

    fig13

  20. 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.

  21. Save and execute the test. Note that the test will execute for each row in the data array, for a total of five iterations.

  22. To use reference data from the data array in a code behind method, follow these steps.

  23. 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.

  24. Choose Visual Basic or C#.

  25. Use the Data property followed by the index of the column to reference data from the grid. For example:

    
    //Reference a column by name
    Pages.Bing.SbFormQText.Text = Data["Numbers"].ToString();
    //Reference a column by index (zero based)
    Pages.Bing.SbFormQText.Text = Data[0].ToString();
    
    
    'Reference a column by name
     Pages.Bing.SbFormQText.Text = Data("Numbers").ToString()
    'Reference a column by index (zero based)
     Pages.Bing.SbFormQText.Text = Data(0).ToString()
    
    
  26. Save and build project.

  27. Execute your test. Note that the test will be executed for each row in the data array.

  28. Standalone
    Standalone Version
    VS Plugin
    VS Plugin