I am using Ranorex version 2.3.8.10854. I followed the example in User Guide for Data-Test driven to read data from a csv file. I got "The type or namespace name 'CSVConnector' could not be found..." I search in your forum and found out that I had to use System.Data which I did, but I still cannot get it to read from file.
I created the csv file on my desktop and used the following code to refer to it:
CSVConnector csvConnector = new CSVConnector(@"C:\Users\"MyUserName"\Desktop\LookupData.csv")
What seems to be the problem?
here is my code from Program.cs
using System;
using System.Data;
using System.Threading;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
namespace Test1
{
class Program
{
[STAThread]
public static int Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
string logFileName = "Test.rxlog";
Report.Setup(ReportLevel.Info, logFileName, true);
try
{
// Create a new CSVConnector object
CSVConnector csvConnector = new CSVConnector(@"C:\Users\mzammari\Desktop\LookupData.csv");
// Read every row from connector and send to AddVIPApplication.
foreach(DataRow row in csvConnector.Rows)
{
Recording1.AccountID= row["AccountID"].ToString();
Recording1.Start();
}
}
catch (ImageNotFoundException e)
{
Report.Error(e.ToString());
Report.LogData(ReportLevel.Error, "Image not found", e.Feature);
Report.LogData(ReportLevel.Error, "Searched image", e.Image);
error = -1;
}
catch (RanorexException e)
{
Report.Error(e.ToString());
Report.Screenshot();
error = -1;
}
catch (ThreadAbortException)
{
Report.Warn("AbortKey has been pressed");
Thread.ResetAbort();
error = -1;
}
catch (Exception e)
{
Report.Error("Unexpected exception occured: " + e.ToString());
error = -1;
}
Report.End();
return error;
}
}
}