Columns was not created in Data Source (DataCache)

Class library usage, coding and language questions.
andrii.savka
Posts: 21
Joined: Mon Mar 30, 2020 2:10 pm

Columns was not created in Data Source (DataCache)

Post by andrii.savka » Tue Apr 06, 2021 12:52 pm

Hello.

So the main idea is to get the table from UI and to store it in the cache of some data store.
Also, we created some sort of generic data source with the name "GenericDataSource".

How to set and get Columns values. We tried different cases but no luck.
As you can see we created a columns collection and tried to store it.
2021-04-06_14-42-59.png
But it is not working.
2021-04-06_14-42-32.png
Also for getting data source and for adding rows we are using such actions, and the row was added fine:

Code: Select all

public static DataCache GetConnectors(string name)
		{
			return DataSources.Get(name); 
		}

Code: Select all

public static void GenerateNewRow(this DataCache connector, string[] values)
		{
			Ranorex.Core.Data.Row row = new Ranorex.Core.Data.Row(values);
			connector.Rows.Add(row);
			connector.Store();
		}
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Columns was not created in Data Source (DataCache)

Post by odklizec » Wed Apr 07, 2021 8:35 am

Hi Andrii,

Could you please upload a simple test suite with your code and data source? It would make the things simpler to debug ;) Thanks.

I'm using similar code to store data in CSV files and it works quite well. The only major difference I see is that you are declaring rowcollection directly in StoreData parameter, while I'm declaring it before...

Code: Select all

//create CSV data connector
	string connector = "CSVConnector";
	Ranorex.Core.Data.CsvDataConnector csvConnector = new Ranorex.Core.Data.CsvDataConnector(connector,csvOutputPath,true);
	csvConnector.SeparatorChar = ',';
	Ranorex.Core.Data.ColumnCollection propTableColumnsCSV = new Ranorex.Core.Data.ColumnCollection();
	Ranorex.Core.Data.RowCollection propTableRowsCSV = new Ranorex.Core.Data.RowCollection(propTableColumnsCSV);

	//create CSV column headers
	propTableRowsCSV.Add(new string[1]{"resourceKey"});
       ...
// save CSV connector to file
	csvConnector.StoreData(propTableColumnsCSV, propTableRowsCSV);
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

andrii.savka
Posts: 21
Joined: Mon Mar 30, 2020 2:10 pm

Re: Columns was not created in Data Source (DataCache)

Post by andrii.savka » Mon Apr 12, 2021 7:16 pm

Thank you odklizec.

I have used your code as an example and was able to update the data store.