We are using .csv data sources in our tests. We're capturing and updating values to these data columns during the test run and then we want to export what's been written to the columns at the end of the test.
Is there an inbuilt way to do this? I did have a search around but couldn't find anything myself.
Thanks
Dave
Can you export data at the end of the run?
Re: Can you export data at the end of the run?
Hi,
There is no action (code-less way) to do this. But you can export data to CSV file using pretty simple CsvDataConnector code. Please follow this post, where you can find an example code...
https://www.ranorex.com/forum/writing-i ... tml#p34657
There is no action (code-less way) to do this. But you can export data to CSV file using pretty simple CsvDataConnector code. Please follow this post, where you can find an example code...
https://www.ranorex.com/forum/writing-i ... tml#p34657
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Can you export data at the end of the run?
Thank you, that pointed me in the right direction. In the end I came up with this which seems to do the trick.
This might need tweaking if you're trying to work with multiple iterations, all my tests are single iteration so I haven't had to factor that in:
This might need tweaking if you're trying to work with multiple iterations, all my tests are single iteration so I haven't had to factor that in:
Code: Select all
[UserCodeMethod]
public static void ExportData()
{
string csvPath = @"C:\output\" + TestCaseNode.Current.Name + "_" + System.DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".csv";
string headings = "";
string rowData = "";
foreach (var heading in TestCaseNode.Current.DataContext.AvailableDataColumnNames){
headings = headings + heading.ToString() + ",";
}
if (headings.Length > 0){
headings = headings.Substring(0,headings.Length-1);
}
foreach (string cell in TestCaseNode.Current.DataContext.EffectiveRow.Values){
rowData = rowData + cell + ",";
}
if (rowData.Length > 0){
rowData = rowData.Substring(0,rowData.Length-1);
}
StreamWriter sw = File.AppendText(csvPath);
sw.WriteLine(headings);
sw.WriteLine(rowData);
sw.Close();
}