Page 1 of 1

To find the list element which is under many levels

Posted: Fri Aug 18, 2017 5:33 am
by mayur006
Hi,

I am new to Ranorex and posses very little exposure to code.

I wanted to execute a scenario where in a context menu there are multiple list tag(li) element in unordered list(ul) with each li containing the another ul having list of li and so on (upto 4 levels).

Ul1
<li>Abc<li>------Ul2
<li>123<li>-------------ul3
<li>mns<li>----------ul4
<li>890<li>


I want to get the particular li element by its name and then subsequent elements under that . However my problem is that the search should be from the top for number of elements , cause otherwise it looses focus from the particular unordered list.

I tried using below code but it seems only work with id and not by name.

IList<Ranorex.LiTag> TestCodeTemplateListItems = Host.Local.Find<Ranorex.LiTag>("/dom[@domain='xyz']//div[#'vakata-contextmenu']/ul/li[1]/ul/./li");
foreach (Ranorex.LiTag TestCodeTemplateListItem in TestCodeTemplateListItems)

{
TestCodeTemplateListItem.MoveTo();
Ranorex.Report.Screenshot(TestCodeTemplateListItem);
}
}......for 1st ul list

IList<Ranorex.LiTag> Opertional_1st_item_under_operational_listListItems = Host.Local.Find<Ranorex.LiTag>("/dom[@domain='xyz']//div[#'vakata-contextmenu']/ul/li[1]/ul/li[7]/ul/./li");
foreach (Ranorex.LiTag Opertional_1st_item_under_operational_listListItem in Opertional_1st_item_under_operational_listListItems)

{

Opertional_1st_item_under_operational_listListItem.MoveTo();
Ranorex.Report.Screenshot(Opertional_1st_item_under_operational_listListItem);

could you please help me achieve this?

Re: To find the list element which is under many levels

Posted: Fri Aug 18, 2017 6:53 am
by odklizec
Hi,

Please upload a Ranorex snapshot (not screenshot) of the list in question (or at least sample HTML code). This would help us better understand your problem and make the process of creating relevant sample code much easier. Thanks.

Re: To find the list element which is under many levels

Posted: Fri Aug 18, 2017 7:55 am
by mayur006
Hi Odklizec,

Please see the uploaded snapshot

Re: To find the list element which is under many levels

Posted: Tue Aug 22, 2017 1:07 pm
by mayur006
Hi Odklizec,

Could you please provide any suggestion as how to move ahead with the issue?...As I am still unable to figure out any solution :( :?

Re: To find the list element which is under many levels

Posted: Fri Aug 25, 2017 2:00 pm
by Support Team
Hello mayur006,

I'm not sure if I understand your question correctly. I can see in your snapshot file that the LiTag doesn't have an InnerText value. The text, for example for the list item "Create Node" is the value of the ATag.
A-Tag.png
You would have to check the ATag value in your loop and go back to the LiTag from there. The RanoreXPath could look like the following:
/dom[@domain='rgnserver40']//div[#'vakata-contextmenu']/ul//a[@innertext='Create Node']/..
Sincerely,
Bernhard