Trying to log when objects in dropdown are changed

Class library usage, coding and language questions.
Rebus
Posts: 5
Joined: Wed Jan 08, 2014 6:50 pm

Trying to log when objects in dropdown are changed

Post by Rebus » Wed Jan 29, 2014 9:59 pm

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");



}

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

Re: Trying to log when objects in dropdown are changed

Post by Support Team » Fri Jan 31, 2014 3:44 pm

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
.
Image