Page 1 of 1

Trying to log when objects in dropdown are changed

Posted: Wed Jan 29, 2014 9:59 pm
by Rebus
I am trying to create some code that when run tells me if objects were added or removed from a dropdown.

The code I have currently is not working.

I think I may need to convert the objects into strings then add them to a list then compare it with my other list.

IList<ATag> currentList2 = filterOptions.FindDescendants<ATag>();


System.Collections.Generic.List<string> DropdownOps2 = new System.Collections.Generic.List<string>();
DropdownOps2.Add("My Campaigns");
DropdownOps2.Add("My Group");
DropdownOps2.Add("All");
DropdownOps2.Add("Test");


foreach(ATag item in currentList2)
{
string itm = item.InnerText.ToString();

foreach (String value in DropdownOps2){
if(!DropdownOps2.Contains(itm))
Ranorex.Report.Warn(value);

}

if (DropdownOps2.Contains(itm))
Ranorex.Report.Success(itm + " is available");
else
Ranorex.Report.Warn(item + " is not available");



}

Re: Trying to log when objects in dropdown are changed

Posted: Fri Jan 31, 2014 3:44 pm
by Support Team
Hi Rebus,

You can try to use a foreach loop in order to convert the "currentList2" to a string list.
System.Collections.Generic.List<string> currentStringList = new System.Collections.Generic.List<string>();

foreach(ATag item in currentList2)
{
      string itm = item.InnerText.ToString();
      currentStringList.Add(itm);
}
Regards,
Bernhard