Get data from CSV file through CsvDataConnctor

Ranorex Studio, Spy, Recorder, and Driver.
artemcenia
Posts: 2
Joined: Fri May 05, 2017 2:22 pm

Get data from CSV file through CsvDataConnctor

Post by artemcenia » Fri May 05, 2017 2:32 pm

Hi!

Maybe i so bad in search, but I didn't find how reach the data what was connect with CsvDataConnctor.

Test case:
I connected CSV-file to my test case with Tab "Data Source" in properties through CsvDataConnctor.
Question:
How get all data from first row and first column in code module. I need compare this row data from file and what GUI return to me.

Artem,
Ranorex 7.0.1
Windows 7

uhmdown
Posts: 54
Joined: Mon Apr 03, 2017 12:00 pm

Re: Get data from CSV file through CsvDataConnctor

Post by uhmdown » Mon May 08, 2017 12:32 pm

Hi artemcenia,

(Here's the link to the user-guide: https://www.ranorex.com/support/user-gu ... ctors.html)

Here's a quick & dirty step-by-step:

1. In your code module, add a variable by right-clicking anywhere in the file, and select "Insert New Module Variable".
2. Now this variable will be possible to databind to. You can set up the databinding up the rxtst Test Suite file; right-click the SmartFolder or Test Case in which your code module sits, and set up DataSource and DataBinding.
DataSource is for selecting the datasource, and DataBinding is for selecting which columns to bind to variables in the Code Module (or Recording module, if that's what you are using instead).


Try to take it from here; I find that the DataSource and DataBinding dialogues are pretty self-explanatory once you get there.

artemcenia
Posts: 2
Joined: Fri May 05, 2017 2:22 pm

Re: Get data from CSV file through CsvDataConnctor

Post by artemcenia » Tue May 09, 2017 10:07 am

Hi!
thx for response,
But it not what i need exactly.
I'm already using DataBinding. And after this I want to check that my GUI display all data what I insert from CSV-file.
It looks like:
We have list and field for insert data to this list
1. Add 5 item to list in way put data from CSV file
2. Compare CSV file and list items

uhmdown
Posts: 54
Joined: Mon Apr 03, 2017 12:00 pm

Re: Get data from CSV file through CsvDataConnctor

Post by uhmdown » Tue May 09, 2017 11:58 am

Ah ok, got it.

So your SUT contains a GUI box that contains a list of items, and you want to check that the list contains the expected items.

I just set up something similar for myself; there is no out-of-box solution for verifying lists of GUI elements using a DataSource as a checklist.
Here's how I did it.

1. Lets say you have a test case called "GUI verification". In there, create a SmartFolder in which you put a code module called "BuildExpectedList " Databind this to the data from your CSV file.

2. In the BuildExpectedList Code Module, you need to fill up a Collection with your strings from the CSV file, one row at a time (Put the Collection in a class somewhere as a static field).

3. Now, after the "BuildExpectedList " SmartFolder, add a "BuildActualList " Code Module. This one should iterate through the GUI list that you want to verify, and fill up another Collection.

4. Now, after the "BuildActualList " Code module, add a Code module called "CompareLists".

5. In the "CompareLists" Code module, all you need to do is go through the two lists and compare the items. Log each verification result to the report with Fail or Success.


I used Dictionaries for the collections Expected and Actual items, because that lets me check whether items are missing (iterate through ExpectedList and lookup in ActualList), and also if there are any unexpected items (iterate through ActualList and lookup in ExpectedList). That means that you will need a column in your CSV file that can be used as dictionary keys.
Additionally, since each list-item could contain another list of items, I had to nest dictionaries in order to be able to represent the entire structure of the items I needed to verify (and the CSV needed to reflect this as well).

Also, if you want to check order as well, build a second collection using Lists.

You don't have to separate the BuildActualList and CompareLists operations. You can do those in one code module in one loop, instead of two separate ones, but that's up to you.

Make sense?