New to Telerik Test Studio? Download free 30-day trial

Data Driven Find Expressions

I would like to data drive a find expression and use it to perform an action against or verify an element.

Solution

The example below is against this Telerik demo site.

1.Record a Navigate to step. 2.Open the drop-down for the ComboBox. 3.Locate the parent element in the DOM Explorer (see below). Here the Unordered List holds all the child List Item elements. Right click it and select Add to Project Elements.

Add to Project

4.Insert a Coded Step. 5.Use the local data to enter values for the find expression. 6.We will use the Find.ByContent method in the coded step. More information can be found in our Finding Page Elements article. Here's the code for our Script Step:

HtmlListItem listItem = Pages.TelerikExtensionsForASP.UnorderedList.Find.ByContent<HtmlListItem>(Data["Col1"].ToString()); 
Assert.IsNotNull(listItem); 
listItem.Click(); 
Dim listItem As HtmlListItem = Pages.TelerikExtensionsForASP.UnorderedList.Find.ByContent(Of HtmlListItem)(Data("Col1").ToString()) 
Assert.IsNotNull(listItem) 
listItem.Click() 

7.Test Studio Dev uses the data table to find the element in the list, performs an Assert on it, and then clicks it.

Execute test

In this article