How to add additional data to the report's iteration activitiy

Ask general questions here.
User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

How to add additional data to the report's iteration activitiy

Post by odklizec » Wed Mar 04, 2015 4:26 pm

Hi folks,

Sorry for reopening this old thread, but I'm experiencing a problem while adapting the above scenario to my needs.

I want to add an information obtained from the assigned data connector and display it in report after iteration number. It works for the first iteration, but then it fails while processing the second iteration, with error "An item with the same key has already been added.".

Simply, it fails during the attempt to add new key/value to CustomProperties. True, the "key" value "CustomField" is still the same, but so is the "CustomFieldStartingTime" in the above example? So what should I need to do to make it working with TC iterations?

Please check the attached sample project. Thanks!

Ranorex version 5.2.3
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: How to add additional data to the report's iteration activit

Post by Support Team » Thu Mar 05, 2015 5:41 pm

Hi odklizec,

We moved your post into a new thread, since we think it was not really connected to the other one.
The post you are referencing to is this one: Timestamps in Report instead of duration.

Regards,
Markus

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to add additional data to the report's iteration activit

Post by odklizec » Thu Mar 05, 2015 5:45 pm

Hi Markus,

OK, thanks and sorry for the mess. I thought it was more or less about the same problem ;)
Pavel Kudrys
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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: How to add additional data to the report's iteration activit

Post by Support Team » Mon Mar 09, 2015 2:01 pm

Hello odklizec,

The problem is that you can’t add duplicate keys to a dictionary. I’ve solved the issue as shown below:

Replace:
Ranorex.Core.Reporting.ActivityStack.Instance.VisitAll(a =>  
	{  
														
															
		if(a.GetType().Name=="TestIterationActivity")  
		{                       
			(a as Activity).CustomProperties.Add("CustomField", " TC: " + " Location: " + cm_Location);
		
		}
		return true;  
	});
with:
var actSt = Ranorex.Core.Reporting.ActivityStack.Instance;
actSt.CurrentActivity.CustomProperties.Add("CustomField", " TC: " + " Location: " + cm_Location);
Hope this helps :)

Regards,
Robert

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to add additional data to the report's iteration activit

Post by odklizec » Mon Mar 09, 2015 3:01 pm

Hi Robert,

Works great! Thanks for the help ;)
Pavel Kudrys
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