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

Use Data Source Columns in Code

Test Studio allows you to insert any custom code in the tests - that includes the option to convert an already recorded step to code and use it that way.

Given that, you may need to use the values from the data source in coded steps and this article describes how to access the data columns through code.

//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() 
//Reference a column by name
Pages.Bing.SbFormQText.Text = Data["Col1"].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("Col1").ToString()

'Reference a column by index (zero based)
Pages.Bing.SbFormQText.Text = Data(0).ToString()

This method can also be applied to a Verification:

//Reference a column by name
Assert.IsTrue(ActiveBrowser.ContainsText(Data["Col1"].ToString()));

//Reference a column by index (zero based)
Assert.IsTrue(ActiveBrowser.ContainsText(Data[0].ToString()));
'Reference a column by name
Assert.IsTrue(ActiveBrowser.ContainsText(Data("Col1").ToString()))

'Reference a column by index (zero based)
Assert.IsTrue(ActiveBrowser.ContainsText(Data(0).ToString()))
In this article
Not finding the help you need? Improve this article