Page 1 of 1

How to retrieve multiple test data from excel?

Posted: Wed Jun 15, 2016 8:25 am
by Dinesh27
Is there any way, where I can retrieve multiple test data based on the excel screenshot I have attached without using inbuilt UI for data binding?

When I run the code, the code should interlink between the test case name and with its own set of test data.
Iteration should happen based on count of test data of each test case without UI support. How to write a code for this?

Re: How to retrieve multiple test data from excel?

Posted: Fri Jun 17, 2016 7:59 am
by odklizec
Hi Dinesh,

Is there any particular reason, why you cannot put each table to its own excel worksheet? How I see it, your existing worksheet contains three separate data tables for three separate test cases, right? So why not to make your life easier and create three separate worksheets and three separate data connectors, using built-in data binding functionality?

If I were you, I would use code only if there is no built-in or better/faster way to achieve what you want with existing Ranorex functionality. The more code you add to your tests, the higher probability your tests will fail at some point ;) But even if you insist on using coded way, it would be much easier to use separate worksheets instead of single one.

If you still think you can do it better in code, then you need to use
Ranorex.Core.Data.ExcelDataConnector, where you can define range of cells for given excel file and worksheet.

An example how to use ExcelDataConnector can be found for example here:
http://www.ranorex.com/forum/how-to-acc ... tml#p23324

But I think it will not work with single worksheet anyway (even if you define worksheet range), because there are three separate headers for each test data? So you will still need to use three separate worksheets.