Data extraction & Dynamic data binding during run-time

15 posts, 0 answers
  1. Yogi
    Yogi avatar
    3 posts
    Member since:
    Oct 2010

    Posted 13 Dec 2010 Link to this post

    I have an application which will use the data from an Excel file which will be dynamically generated during execution.
    I need to know,
    1. How to extract data from the application and export it to an external excel sheet
    2. Is there any option to bind an external Excel file during execution

    Regards,
    Yogi
  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 13 Dec 2010 Link to this post

    Hi Yoganand,

    You can get the text of most elements using code something like this:

    Pages.Bing.SbFormQText.Text;

    To write into an Excel file you will have to implement your own code. WebUI does not include any API's for reading/writing to Excel files from your own coded steps. Here's a Microsoft article describing one possible approach.

    Can you give us more details about what you're trying to accomplish with binding an external Excel file during execution? Currently there is no built-in feature to do this, but there are a couple of possible tricks we can show you, depending on what exactly you are trying to accomplish.


    Regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  3. Yogi
    Yogi avatar
    3 posts
    Member since:
    Oct 2010

    Posted 13 Dec 2010 Link to this post

    Hi Cody,

    Thanks for your response.
    I'll give a try the steps specified in the Microsoft article and let you know.

    In our application, based on the initial input, the application will generate an unique excel file which contains some data that needs to be feed to the application to perform an action. So it will be better if there is a technique or code to bind the excel sheet during run-time. This will help us to run the test without manual intervention.

    Regards,
    Yogi
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 13 Dec 2010 Link to this post

    Hello Yoganand,

    Attached is a sample test of one of the tricks we can do. Basically a single test can only be bound to one specific data source/file. But what the attached test project does is split the testing into two parts, a main test and a sub test.

    • The main test is data driven and gets its input from a single excel file. It dynamically swaps out the file that the subtest is bound to just before calling the subtest.
    • The subtest is bound to one specific file. When it gets control it opens and begins reading from the file that the main test put there for it to read.
    Using this trick you can probably do what you're after.

    Regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  5. Yogi
    Yogi avatar
    3 posts
    Member since:
    Oct 2010

    Posted 15 Dec 2010 Link to this post

    Hello Cody,

    Thanks for your support. Given trick works only if the sub test is using a static file name.
    I found out a method in MSDN forum to bind excel data source during run-time.

    <DataSource("System.Data.Odbc",
    "Dsn=Excel Files;dbq=C:\\POC\\Data\\testdata.xls;defaultdir=.;driverid=1046;maxbuffersize=2048;pagetimeout=5",
    "Login$",
    DataAccessMethod.Sequential)>
    <TestMethod()>
    Public Sub WebAiiTest1()
        Dim row = TestContext.DataRow.Table.Rows(1)
        Dim actual = row("col2")
        MsgBox(actual)
    End Sub

    The above code is working fine. But I'm unable to control the iteration, i.e, if the excel sheet has 10 rows, then the test is executed for 10 times.
    Please let me know is there any method or trick to control the iteration by specifying a particular row to execute.

    Thanks,
    Yogi
  6. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 15 Dec 2010 Link to this post

    Hello Yogi,

    The code you have posted does work well for a coded unit test. However keep in mind that WebAii tests (i.e. .aii tests) are not coded unit tests. They do not honor the DataSource attribute the way coded unit tests do.

    Unfortunately you cannot programmatically control which row or rows of data will be used from the data source. The best we can do is to apply row filtering during the data binding setup as shown in the attached screenshot.

    Regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  7. Veera
    Veera avatar
    25 posts
    Member since:
    Jul 2010

    Posted 20 Dec 2010 Link to this post

    Hi Cody,
    Is there any chance that we can get this feature of controling the iteration in any of the future releases of telerik? This feature is really needed for us.  Pls let us know.. Thanks!!!!

    Thanks,
    Veera
  8. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 20 Dec 2010 Link to this post

    Hello Veeraraghavan,

    I have entered feature request 102982 for this. I cannot specify when (or even if) we'll be able to implement this in a future version. All I can say is that it will be considered by our product manager.

    Can you explain to me your business case why you need this? This will help our product manager better understand why this such an important feature to you.

    Best wishes,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  9. Veera
    Veera avatar
    25 posts
    Member since:
    Jul 2010

    Posted 21 Dec 2010 Link to this post

    This feature is required inorder to change multiple data worksheet for a same script. Currently our application Has different modules that has data inputs . Each module has seperate worksheet in a single excel. As long as the module did not intereacting with one another we do not have issues. If the modules interact then we have problem.
    This feature is required as we can Dynamically associate the excel file to the test scripts when required!!!

    Hope this helps!!

    Thanks,
    Veera
  10. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 21 Dec 2010 Link to this post

    Hi Veeraraghavan,

    Thank you for the additional information. I've passed it along to the product manager.

    I would like to better understand this module interaction that you talk about. From the very limited understanding I have of your application and testing needs, it would seem you would have a set of test cases and one separate test per test case, possibly one for each module, and each test case for a module would be data bound to one sheet from your Excel file.

    I'm pretty sure this is for the case of "As long as the module did not intereacting with one another" as you talk about. I am not yet fully understanding how dynamic data binding helps testing with your module interaction.

    Greetings,
    Cody
    the Telerik team

    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  11. Veera
    Veera avatar
    25 posts
    Member since:
    Jul 2010

    Posted 22 Dec 2010 Link to this post

    Hi Cody,
    Thanks, think at least I made justice this time in my explanation.
    We have module like
    • Entity
    • Personnel
    • Contact Etc
    Each module interacts with one another by associating a entity with Personnel, Contact etc... We do verification of contacts in entity module and vice-versa ....Same Verification needs to be extended for Personnel, entity.
    Currently, we have worksheet per module. If I have to verify the entities details in contact module, we are not able achieve that as both entity details and contact details are from diff worksheet and both info are required in order to complete the verification. which is not possible at this moment!

    Hope this helps!!!
  12. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 27 Dec 2010 Link to this post

    Hi Yogi,

    Thank you for the clarification. I think I begin to understand your test case now. Based on which Personnel you associate with an Entity you want the same type of test to run, but with different data that goes along with that Personnel record. Do I understand better now?

    All the best,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  13. Veera
    Veera avatar
    25 posts
    Member since:
    Jul 2010

    Posted 28 Dec 2010 Link to this post

    Hi Cody,

    Only one which I would like to highlight here is There will not be one to one mapping between Personnel and Entity.  One Personnel to Multiple entities and One Entity to Multiple Personnel. Hope this helps

    Thanks,
    Veera

  14. Veera
    Veera avatar
    25 posts
    Member since:
    Jul 2010

    Posted 04 Jan 2011 Link to this post

    Yes.  Correct!!!
  15. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 04 Jan 2011 Link to this post

    Hello Yogi,

    Thanks! I am pretty sure I understand your business needs now.

    Kind regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!