how to select a child DivTag from a parent?

Best practices, code snippets for common functionality, examples, and guidelines.
ereid
Posts: 3
Joined: Fri Jan 04, 2019 6:09 pm

how to select a child DivTag from a parent?

Post by ereid » Fri Jan 04, 2019 6:25 pm

Hi

I am new to the forum and using Ranorex. I am trying to select the innerText on a child DivTag and need some help to do so, using the User Code. Can anyone one you help me. Attached is an image of the test case I am working on.
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: how to select a child DivTag from a parent?

Post by odklizec » Tue Jan 08, 2019 8:36 am

Hi,

Please upload a Ranorex snapshot (NOT screenshot) of the problematic menu. Screenshot is unfortunately useless as nobody here probably wants to retype xpaths from screenshot. The things are much easier to understand and explain with snapshots! ;)

Additionally, please describe what exactly do you want to achieve? It's not quite clear to me what's your workflow and goal?
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

ereid
Posts: 3
Joined: Fri Jan 04, 2019 6:09 pm

Re: how to select a child DivTag from a parent?

Post by ereid » Tue Jan 08, 2019 1:47 pm

public void SelectMenuItem(string ItemtoSelect, RepoItemInfo MenuItemInfo)
{
WebDocument webDoc = "/dom[@domain='"+ SelDom +"']";
var dropdown = webDoc.FindSingle<UlTag>(".//iframe[@name='main']//div[#'ctl00_phDS_ds_ToolBar_menu13']/ul");
var options = dropdown.FindDescendants<DivTag>();

var found = false;

foreach(var opt in options)
{
if(opt.InnerText == ItemtoSelect)
{
opt.Click();
found = true;
break;
}
}

if(found == false)
{
throw new InvalidOperationException("Select Menu Item option not found for ");
}
}