Refreshing externally modifed CSV in user code?

Class library usage, coding and language questions.
atam
Posts: 15
Joined: Wed Jan 16, 2013 2:58 pm
Contact:

Refreshing externally modifed CSV in user code?

Post by atam » Mon Jun 10, 2013 10:28 am

Hi,

We modify our CSV data files externally, and using UserCode modules to increment certain data. The problem is that this data does not load/refresh unless we hit the refresh button in "Manage Data Scources". Is there a way to refresh/reload the data in a UserCode module?

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Refreshing externally modifed CSV in user code?

Post by Support Team » Wed Jun 12, 2013 10:52 am

Hi,

How do you exactly increment the data in UserCode and what do you exactly mean with the file is externally modified?
Could you please describe in detail what you are trying to do?

Thanks,
Markus
.
Image

atam
Posts: 15
Joined: Wed Jan 16, 2013 2:58 pm
Contact:

Re: Refreshing externally modifed CSV in user code?

Post by atam » Thu Jun 13, 2013 10:08 am

Hi,

Well, I have attached a screenshot. In the setup, we have created a recording increment.. which basically contains UserCode to manipulate the CSV data. Right now we add a random number after certain data.

Before increment: Username13123
After increment: Username23524

The increment occurs, but the new data is used on the next execution of the test case.

Execution 1 (We increment to Username23524 in this execution): Username13123 is used.
Execution 2: Username23524

Hope I have made my self more clearer.

Thanks.
Attachments
screenincrement.png
screenincrement.png (7.43 KiB) Viewed 921 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Refreshing externally modifed CSV in user code?

Post by Support Team » Fri Jun 14, 2013 4:04 pm

Hello,

Could you please describe why you want to to change values in your data source?
In general, it's not recommended to modify the data source during a test run.

I would recommend you to increment your variable in the Init() method of your incrementBasicSetup.UserCode.cs file. This would be executed before your recorded actions.
private void Init()
{
    // Your recording specific initialization code goes here.            
    varUsername = varUsername + new Random().Next();           
};
In that case, you wouldn't need to modify values in your CSV file.

Another approach would be to put your your Recordings (LoginIE and CreateCustomer) into a nested Test Case. Then, your current values (after increment) will be used for user name as shown in the screenshot below.

Regards,
Markus (T)
Attachments
nestedTC.PNG
nestedTC.PNG (11.61 KiB) Viewed 902 times
.
Image

atam
Posts: 15
Joined: Wed Jan 16, 2013 2:58 pm
Contact:

Re: Refreshing externally modifed CSV in user code?

Post by atam » Tue Sep 10, 2013 12:08 pm

Hi,

Thanks for your response.

The variable part is interesting.

Cant seem to access that variable.

We create the variable in the ranorex studio and then bind it to the CSV.

But how do we access it in custom code?

private void Init()
{
// Your recording specific initialization code goes here.
customer = customer + new Random().Next();
};

Throws an error (doesnt exist)

I have attached a screenashot on how the variable is binded in Ranorex.

Thanks
Attachments
screen.png
screen.png (31.39 KiB) Viewed 850 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Refreshing externally modifed CSV in user code?

Post by Support Team » Wed Sep 11, 2013 4:25 pm

Hello,

Is it possible to log the value for customer using:
Report.Info(customer);
How did you create your variable 'customer'?
(using 'Variables' button in Recording module or using 'Insert Module Variable' in User Code file)
Does it work with other created variables?
Which Ranorex version do you use?

Regards,
Markus (T)
.
Image