This is a migrated thread and some comments may be shown as answers.

DataBinding through CodedStep

17 Answers 203 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
N1t1nA
Top achievements
Rank 1
N1t1nA asked on 16 Jun 2011, 10:33 PM
How to bind the Data (Excel, CSV etc) through Coded Step
I am not able to see Text under the Properties, I had bind the SearchData.xlsx file. I want to write the Coded Step for complete data binding.
Is this the only way to do the same
// You can reference the column by index

    Pages.Google.QText.Text = (string)Data[0];

// Or by name

    Pages.Google.QText.Text = (string)Data["Numbers"];

or Is there any other way to acess the data from External source ?

17 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 21 Jun 2011, 04:00 PM
Hi Nitin,

You can't do data binding through UI when you are using coded step. In this case you have to do it in code, because when you are doing a coded step we don't know what is inside. That is the reason you don't see the "Text" property, because in your coded step you can use other property instead.

Best wishes,
Plamen
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Shashi
Top achievements
Rank 1
answered on 21 Jun 2011, 04:52 PM
Nitin,

Have you tried databinding before you convert to a coded step and adding other code?  You should be able to do the databinding in the UI as long as the step is recordable and has bindable parameters.

Shashi
0
N1t1nA
Top achievements
Rank 1
answered on 22 Jun 2011, 05:22 AM
Hi Plamen and Shashi

I already bind the data using (Excel, CSV) using Recording method in Telerik TestStudio Standalone, which works fine for me.
but if I enter 3 rows for username in excel file , it executes 3 times in my test.

Now what I want is to access particular sinlge row using Coded Step or Recording mode. I think it is possible only via Coded Step?.

Could you please help how to acess one particular row from (Excel, CSV) and input into my application.
0
Plamen
Telerik team
answered on 24 Jun 2011, 05:05 PM
Hi Nitin,

I understand your request, but Test Studio doesn't offer access any specific row at random. The only way to select, a particular single row is to use Coded Step. If you search on the internet you'll find many articles explaining how to open and read the contents of the excel files.

Kind regards,
Plamen
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
0
N1t1nA
Top achievements
Rank 1
answered on 27 Jun 2011, 08:27 AM
Hi
Could you provide the appropriate link

Thanks
0
Accepted
Plamen
Telerik team
answered on 27 Jun 2011, 03:29 PM
Hello Nitin,

I have searched on the internet and found some samples how to open Excel files. Two of the most popular ways are:

1. Using OleDB provider here.
2. Using Microsoft.Office.Interop.Excel namespace here.

You can check at Microsoft MSDN library too.  link 

If I were you, I would first open the Excel file in the main constructor and then I would assign the "DataSet" to property of type "DataTable"  as you can see on the attached picture. After that, this property can be used in the Coded Step to implement the logic you want. 

You can try different approach if you want, to see which one works for you. I hope this helps!

Kind regards,
Plamen
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
0
N1t1nA
Top achievements
Rank 1
answered on 28 Jun 2011, 05:11 AM
Thankyou Plamen

This really helps :)
I would suggest to put these kind of things in online documentation of Telerik Test Studio.
0
Clifton
Top achievements
Rank 1
answered on 01 Aug 2013, 08:25 PM
Hello, I'm trying this approach and was wondering, if you need the test to run x amount of times (The number of rows in the sheet), 

How do you do it? 
0
Cody
Telerik team
answered on 02 Aug 2013, 01:40 PM
Hi Clifton,

If you want your test to run N times (once per row of data) why not use our standard data driven feature instead? It was designed to work exactly that way.

Regards,
Cody
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Clifton
Top achievements
Rank 1
answered on 02 Aug 2013, 01:46 PM
Hey Cody, 
Thanks for the reply. I'm familiar with the data driven feature and its limitations. I'm looking for a way to change the data sheet being used based on a configuration variable. 

I would like to have test cases for production environment and development environment. Since I have to maintain two sets of data, I'll like to run the test using a "Prod" sheet if i'm running live or a "Dev" sheet if not. 

Hope that makes more sense. 
0
Cody
Telerik team
answered on 02 Aug 2013, 01:55 PM
Hello Clifton,

Ah I see. This folds in with the other reply on your support ticket 722244 I just send a couple of minutes ago (with more detail). Let's continue this discussion there instead.

Regards,
Cody
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Abc
Top achievements
Rank 1
answered on 10 Sep 2014, 07:54 AM
could you please let me know how to do data binding if I am writing coded steps in telerik test studio
0
Cody
Telerik team
answered on 11 Sep 2014, 11:14 PM
Hi,

That is what this code sample is all about.

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Gavin
Top achievements
Rank 1
answered on 20 May 2016, 10:25 PM
Dead link.. any updates ?
0
Boyan Boev
Telerik team
answered on 25 May 2016, 01:43 PM
Hello Gavin,

Please excuse us.

Here is the correct link.

Hope that helps.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
SHK
Top achievements
Rank 1
answered on 28 Jul 2016, 01:46 PM

Hi ,

I have a similar requirement as posted by Clifton i.e. use different data sheets(excels) for different environments and instruct the test script to use the relevant sheet using code. You mentioned in your reply to Clifton that this discussion would be continued in the support ticket but looks like I do not have access to see that discussion. Can you please help me too with the solution.

Thank you,

SHK

0
Boyan Boev
Telerik team
answered on 02 Aug 2016, 12:18 PM
Hi,

Here is the answer in the ticket that you cannot see:

If a parent test is reading and creating its own Dataset object, the only way for a child test to get the data is if the parent test stores the data in some sort of a global variable/object that the child test can refer to, but it could only get at it from the coded steps of the child test. You won't be able to use the standard Test Studio data driven approach for non-coded steps.

I am thinking you'd be better off implementing your own Execution Extension DLL. This DLL "extends" the functionality of Test Studio tests. All hooks contained in this DLL will get called always, by every test in every project ever run on that machine.

The hook you're after is this one:
public System.Data.DataTable OnInitializeDataSource(ExecutionContext executionContext)

Here you create your own DataTable object and Test Studio will use it as the data source for all data driven tests. In the ExecutionContext is the name of the test. You can optionally filter by the name of the test and adjust what you do. Returning NULL tells Test Studio to revert to its default behavior. The key advantage of taking this approach is that your child tests can use the InheritParentDataSource test property and consume the data in the standard Test Studio fashion.

Hope that helps.

Regards,
Boyan Boev
Telerik by Progress
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
N1t1nA
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Shashi
Top achievements
Rank 1
N1t1nA
Top achievements
Rank 1
Clifton
Top achievements
Rank 1
Cody
Telerik team
Abc
Top achievements
Rank 1
Gavin
Top achievements
Rank 1
Boyan Boev
Telerik team
SHK
Top achievements
Rank 1
Share this question
or