Page 1 of 1

Iterating through the ContextMenu to GetValues

Posted: Mon Mar 26, 2018 3:43 pm
by deatchlock
Hi,

I am trying to iterate through the ContextMenu and too read out Text values from the items and to store them. So far I have managed this:

IList<Ranorex.ContextMenu> contextList = contextRepoItem.CreateAdapters<Ranorex.ContextMenu>();

foreach(Ranorex.ContextMenu item in contextList)
{
string captionString = item.Element.GetAttributeValueText("Text");
//write new line to csv
propTableRowsCSV.Add(new string[]{captionString});
item.MoveTo();
Ranorex.Report.Screenshot(item);
Ranorex.Report.Info(captionString);
Ranorex.Delay.Milliseconds(200);
}
//save CSV connector to file
csvConnector.StoreData(propTableColumnsCSV, propTableRowsCSV);
}

It opens ContextMenu which contains five elemnts inside but no value is taken and it does not iterate through the list. In the end I get only screenshot from the ContextMenu ( list ). And yes not even the first value is stored to the CSV. Any assistance would be appreciated :)

Re: Iterating through the ContextMenu to GetValues

Posted: Tue Mar 27, 2018 7:54 am
by odklizec
Hi,

You must replace this declaration Ranorex.ContextMenu with this Ranorex.ListItem and the contextRepoItem must point to xptah, returning "list" of ListItmes (e.g. /contextmenu/listitem). Hope this helps?

Re: Iterating through the ContextMenu to GetValues

Posted: Wed Mar 28, 2018 9:00 am
by deatchlock
Hi odklizec,

thank you :) it did the job.