Test data from .csv file : Automation API

Test data from .csv file

Class library usage, coding and language questions.

Test data from .csv file

Postby omayer » Thu Jul 14, 2011 8:15 am

is there code snippet for read through the entire .csv file and passing the data to test method in ranorex,
Thank you,
Beginner
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby Support Team » Thu Jul 14, 2011 4:28 pm

Hi,

Do you know the Ranorex Studio "Manage Data Source" functionality?
You can easily load your (csv, excel, ...) files with all data into your project and you can easily access them.
For additional information see the link below: http://www.ranorex.com/support/user-guide-20/lesson-3-data-driven-testing.html
If you mean something else please explain it in a more detailed way.

Thanks in advance!

Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Test data from .csv file

Postby omayer » Sat Jul 16, 2011 3:08 am

how to load csv file w/out using "Manage Data Source" functionality, i like to creae a function that will read the .csv file from external source then passing data as function parameter.
Thank you
Beginner
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby Support Team » Mon Jul 18, 2011 1:02 pm

Hi,

if you do not like to use our new data connectors with data binding, you can use attached CSVConnector.
Following code sample shows you how to use it:
...
try
{
	// Create a new CSVConnector object
	CSVConnector csvConnector = new CSVConnector(@"../../data.csv");

	// Read every row from connector and send to AddVIPApplication.
	foreach(System.Data.DataRow row in csvConnector.Rows)
	{
		String str1 = row[0].ToString();
		String str2  = row[1].ToString();
	}
}
catch (RanorexException e)
{
...

Regards,
Tobias
Support Team
Attachments
CSVConnector.cs
CSVConnector
(2.14 KiB) Downloaded 35 times
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Test data from .csv file

Postby omayer » Mon Jul 18, 2011 4:10 pm

Thank you Markus, I really like the dataconnecters and binding feature in Ranorex, the problem i am having w/binding data w/parameter, I am working on it , will keep you posted the progress.
Thank you
Beginner
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby omayer » Tue Jul 19, 2011 9:34 pm

how to view the data str1, I tried to use messagebox.show but no go

try
{
// Create a new CSVConnector object
CSVConnector csvConnector = new CSVConnector(@"../../data.csv");

// Read every row from connector and send to AddVIPApplication.
foreach(System.Data.DataRow row in csvConnector.Rows)
{
String str1 = row[0].ToString();
String str2 = row[1].ToString();
}
}
catch (RanorexException e)
{
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby Support Team » Wed Jul 20, 2011 1:20 pm

Hi,

No idea why MessageBox.Show should not work, but instead you can use Console.WriteLine(), or log the data to the Ranorex Report file, or you set a breakpoint and use the debugging mode of Studio to read the data for str1.

Regards,
Peter
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Test data from .csv file

Postby omayer » Wed Jul 20, 2011 2:28 pm

Thank you Peter, I might need instruction or what to do w/attached file "CSVConnector.cs" on previous post .
Thanks
Beginner
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby Support Team » Wed Jul 20, 2011 2:50 pm

Hi,

Attached you will find the old Data Drive Sample. In this sample the VIP Application uses the CSV Connector.
Data Driven Test.zip
Data Driven Test
(21.64 KiB) Downloaded 33 times

Regards,
Peter
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Test data from .csv file

Postby omayer » Wed Jul 20, 2011 3:00 pm

Thank you Peter
Beginner
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby omayer » Wed Jul 20, 2011 5:15 pm

i amg getting the error " Index was outside the bounds of the array. "

Code: Select all
void ITestModule.Run()   

           
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;
                                    // Create a new CSVConnector object

CSVConnector csvConnector = new CSVConnector(@"C:\Automation_Ranorex\TestData.csv");
            // Read every row from connector and send to AddVIPApplication.
               foreach(DataRow row in csvConnector.Rows)
      {                
         
                  LoginTo.userId = row["userID"].ToString();
                  LoginTo.passWord = row["passWord"].ToString();
                  MessageBox.Show(LoginTo.userId);
                                             
                 } 




Thanks
Beginner
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby omayer » Thu Jul 21, 2011 5:20 am

Thank you all, csvconnector working as expected.
Beginner
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby omayer » Thu Dec 08, 2011 5:33 pm

How to parse data in csv File that contains this format "lastname, firstname (company name)". Thank you in advance...beginner
Tipu
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Re: Test data from .csv file

Postby Support Team » Fri Dec 09, 2011 1:38 pm

Hi,

How to parse data in csv File that contains this format "lastname, firstname (company name)".

Like you have done it, you just have to replace "userID" with "lastname", "passWord" with "firstname" and so on.

Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Test data from .csv file

Postby omayer » Sun Dec 11, 2011 7:58 pm

I do have data in csv file that looks like this " omayer,baba-(testing field)" . Now when that field gets parsed its value display as "omayer. Not the entire data, so how will i get the data that read as " omayer,baba-(testing field)"
Thank you
Beginner
Tipu
omayer
 
Posts: 240
Joined: Thu Oct 28, 2010 7:14 pm

Next

Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests