To find the list element which is under many levels

Ask general questions here.
mayur006
Posts: 8
Joined: Fri Jun 30, 2017 2:54 am

To find the list element which is under many levels

Post by mayur006 » Fri Aug 18, 2017 5:33 am

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?
Attachments
Context_ListMenu Item.rxsnp
snapshot
(217.74 KiB) Downloaded 30 times
Last edited by mayur006 on Fri Aug 18, 2017 7:54 am, edited 1 time in total.

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

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

Post by odklizec » Fri Aug 18, 2017 6:53 am

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

mayur006
Posts: 8
Joined: Fri Jun 30, 2017 2:54 am

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

Post by mayur006 » Fri Aug 18, 2017 7:55 am

Hi Odklizec,

Please see the uploaded snapshot

mayur006
Posts: 8
Joined: Fri Jun 30, 2017 2:54 am

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

Post by mayur006 » Tue Aug 22, 2017 1:07 pm

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

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

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

Post by Support Team » Fri Aug 25, 2017 2:00 pm

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
A-Tag.png (4.95 KiB) Viewed 454 times
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
.
Image