Page 1 of 1

CSV File Reading/Writing

Posted: Mon Jun 25, 2012 9:13 am
by nandeesh
Hi,

I Used the below code to read data from a csv file. Its working fine. but its displaying all the rows rows.count times. Even if i remove foreach statement same result i am getting.
1. How i can get each row values separately or a particular value for testing from a csv file..?
2. How to add new rows of data to an existing csv file (D:\\CSV\\csvFile.csv) for testing ..?

Help me out.
Thanks.

Code: Select all

CsvDataConnector csvConnector = new Ranorex.Core.Data.CsvDataConnector("CSVConnector","D:\\CSV\\csvFile.csv",true);
csvConnector.SeparatorChar = ',';
ColumnCollection outColCollection;  
			
RowCollection outRowCollection;
csvConnector.LoadData(out outColCollection, out outRowCollection);
foreach(Ranorex.Core.Data.Row dataRow in outRowCollection)
{ 
	Report.Info(""+dataRow["NUMBER"].ToString());
  	Report.Info(""+dataRow["Name"].ToString());  
}

Re: CSV File Reading/Writing

Posted: Tue Jun 26, 2012 10:05 am
by Support Team
Hi,
nandeesh wrote:1. How i can get each row values separately or a particular value for testing from a csv file..?
Basically you can get the whole array of values of a specific row (defined in the foreach loop) using following code snippet:
...
string[] values = dataRow.Values;
...
nandeesh wrote:2. How to add new rows of data to an existing csv file (D:\\CSV\\csvFile.csv) for testing ..?
To write back data to your CSV file in code you can use following code snippet:
...
outRowCollection.Add(new string[2]{"10","Nandeesh"});
csvConnector.StoreData(outColCollection, outRowCollection);
...
Regards,
Tobias
Ranorex Tea,

Re: CSV File Reading/Writing

Posted: Tue Jun 26, 2012 12:03 pm
by nandeesh
Thanks Tobias.

Its working fine. Its adding.

Re: CSV File Reading/Writing

Posted: Wed Oct 31, 2012 8:56 am
by Madan
Here is my test scenbario:
1.Login as User A
2.Go to Change Password
3.Change Password
4.Now, I want User A to make login with this password.

How can I implement this in Ranorex.pls reply asap.

Thanks,
Madan Singh

Re: CSV File Reading/Writing

Posted: Wed Oct 31, 2012 4:54 pm
by Support Team
Hello,

The easiest way to do that is to record all actions with the 'Ranorex Recorder'.

Please take a look at the section Ranorex Recorder in our User Guide.

Regards,
Markus (T)

Re: CSV File Reading/Writing

Posted: Thu Nov 01, 2012 4:18 am
by Madan
Markus,

In my script, password get changed.In next run I want to make login with that password.
So how can i do that so that every time password get changed and am able to login with new password.

please tell me the whole code with example.

Also, how to write in data table in ranorex.

Thanks,
Madan Singh

Re: CSV File Reading/Writing

Posted: Mon Nov 05, 2012 3:29 pm
by Support Team
Hello,

You could use 'Global Parameter' to set values within a test run.

Code: Select all

TestSuite.Current.Parameters["Password"] = "newPassword";
If you want to use these values in the next run you could use a CSV file.
The following example shows how to use this concept:

Code: Select all

string newPassword = "YourNewPassword";
string path = "C:\\Users\\user\\Documents\\test.csv";
string connector = "Params";

Ranorex.Core.Data.CsvDataConnector csvConnector = new Ranorex.Core.Data.CsvDataConnector(connector,path,true);
csvConnector.SeparatorChar = ',';
Ranorex.Core.Data.ColumnCollection inputCol = new Ranorex.Core.Data.ColumnCollection();
Ranorex.Core.Data.RowCollection outputRow = new Ranorex.Core.Data.RowCollection(inputCol);

outputRow.Add(new string[1]{"Password"});
outputRow.Add(new string[1]{newPassword});

csvConnector.StoreData(inputCol, outputRow);
Regards,
Markus (T)

Re: CSV File Reading/Writing

Posted: Mon Dec 17, 2012 4:37 pm
by Madan
Hi,

I want to click 'delete' button' for a particular element located on my application page.
Problem on this page is, a number of different 'delete' buttons exist for every element located on app page.
how to click on that particular delete button for that particular element.

Element link and delete button position can vary if some other element get created on that page.

Pls reply asap.

Thanks,
Madan Singh

Re: CSV File Reading/Writing

Posted: Tue Dec 18, 2012 2:23 pm
by Support Team
Hi,

For the next time it would be great if you could create a new topic if you have a question concerning another problem. This would help others and would make the forum clearer.
In order to analyze your problem we would need a Ranorex snapshot file of your application when the different delete buttons are shown.
Following link will show you how to generate a snapshot file:
Creating Ranorex Snapshot Files.

Regards,
Markus