Iterating through the ContextMenu to GetValues

Ask general questions here.
deatchlock
Posts: 34
Joined: Mon Mar 19, 2018 10:02 am

Iterating through the ContextMenu to GetValues

Post by deatchlock » Mon Mar 26, 2018 3:43 pm

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 :)
You do not have the required permissions to view the files attached to this post.

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

Re: Iterating through the ContextMenu to GetValues

Post by odklizec » Tue Mar 27, 2018 7:54 am

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?
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

deatchlock
Posts: 34
Joined: Mon Mar 19, 2018 10:02 am

Re: Iterating through the ContextMenu to GetValues

Post by deatchlock » Wed Mar 28, 2018 9:00 am

Hi odklizec,

thank you :) it did the job.