DataBinding through CodedStep

18 posts, 1 answers
  1. N1t1nA
    N1t1nA avatar
    37 posts
    Member since:
    Mar 2011

    Posted 16 Jun 2011 Link to this post

    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 ?
  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 21 Jun 2011 Link to this post

    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 >>
  3. Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 21 Jun 2011 Link to this post

    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
  4. N1t1nA
    N1t1nA avatar
    37 posts
    Member since:
    Mar 2011

    Posted 22 Jun 2011 Link to this post

    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.
  5. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 24 Jun 2011 Link to this post

    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?
  6. N1t1nA
    N1t1nA avatar
    37 posts
    Member since:
    Mar 2011

    Posted 27 Jun 2011 Link to this post

    Hi
    Could you provide the appropriate link

    Thanks
  7. Answer
    Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 27 Jun 2011 Link to this post

    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?
  8. N1t1nA
    N1t1nA avatar
    37 posts
    Member since:
    Mar 2011

    Posted 28 Jun 2011 Link to this post

    Thankyou Plamen

    This really helps :)
    I would suggest to put these kind of things in online documentation of Telerik Test Studio.
  9. Clifton
    Clifton avatar
    2 posts
    Member since:
    Oct 2011

    Posted 01 Aug 2013 Link to this post

    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? 
  10. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 02 Aug 2013 Link to this post

    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
  11. Clifton
    Clifton avatar
    2 posts
    Member since:
    Oct 2011

    Posted 02 Aug 2013 Link to this post

    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. 
  12. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 02 Aug 2013 Link to this post

    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
  13. Abc
    Abc avatar
    5 posts
    Member since:
    Aug 2014

    Posted 10 Sep 2014 in reply to Plamen Link to this post

    could you please let me know how to do data binding if I am writing coded steps in telerik test studio
  14. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 11 Sep 2014 Link to this post

    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
     
  15. Gavin
    Gavin avatar
    5 posts
    Member since:
    Mar 2013

    Posted 20 May in reply to Cody Link to this post

    Dead link.. any updates ?
  16. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 25 May Link to this post

    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
     
  17. SHK
    SHK avatar
    11 posts
    Member since:
    Jul 2015

    Posted 28 Jul in reply to Cody Link to this post

    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

  18. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 02 Aug Link to this post

    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
     
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!