Page 1 of 1

how to select a child DivTag from a parent?

Posted: Fri Jan 04, 2019 6:25 pm
by ereid
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.

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

Posted: Tue Jan 08, 2019 8:36 am
by odklizec
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?

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

Posted: Tue Jan 08, 2019 1:47 pm
by ereid
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 ");
}
}