Page 1 of 1

Problem Splitting RxPath expressions

Posted: Tue Jan 15, 2013 1:27 pm
by jabelshauser
"MyControl" can be found with following RxPath:
/form[@controlname='ContainerForm']/element/container/container[@controlname='MyControl']

But i want it to split in:
- /form[@controlname='ContainerForm']
AND
./container[@controlname='MyControl']
OR
.//container[@controlname='MyControl']

But the control is not found in both cases. Whats wrong ? (Lacking parts of the tree is intented)

Is the interpretation of the docu correct ? :
./ = children of the current element -> only the children of the 1st level, but no further descendants
.// = descendants of the current element -> all descendants including the children of the 1st level

Thanks in advance
Jörg

Re: Problem Splitting RxPath expressions

Posted: Tue Jan 15, 2013 10:20 pm
by Ciege
Can you post your Find/FindSingle line of code?
What error are you receiving?
Did you give enough of a timeout for the element to be found?

Re: Problem Splitting RxPath expressions

Posted: Wed Jan 16, 2013 7:52 am
by jabelshauser
IList<Element> forms = Host.Local.Find(new RxPath("/form[@controlname='ContainerForm']"));
form is now avl. in forms[0]
IList<Element> els = forms[0].Find(new RxPath(".//container[@controlname='MyControl']"));
no element found, els.Count = 0

timeout: if i do a single find like:
Host.Local.Find(new RxPath("/form[@controlname='ContainerForm']/element/container/container[@controlname='MyControl']"));
the method returns after 1-2 seconds the control, should not be a timeout-problem

Re: Problem Splitting RxPath expressions

Posted: Wed Jan 16, 2013 10:09 am
by Support Team
The timeout should not be an issue because you do not specify one. That means Ranorex will just search the element tree once for the specified RanoreXPath.
jabelshauser wrote:.// = descendants of the current element -> all descendants including the children of the 1st level
That's correct. From what I can see the split paths look ok. The only thing that could be different is that you are searching the wrong form, i.e. that the "forms" list contains more than a single form (are there more forms having that control name?). In contrast, the full path searches all possible forms with the "ContainerForm" control name.

Have you debugged the code?
Have you tried to search for the full path right above/below that code and debugged the individual lines?

Regards,
Alex
Ranorex Team

Re: Problem Splitting RxPath expressions

Posted: Wed Jan 16, 2013 10:31 am
by jabelshauser
- The forms-list contains only 1 form. so the form must be right one
- The full path search is succesful. In this case, the control is found.

another test: if i use the whole spare-path, also no success.
forms[0].Find(new RxPath("./element/container/container[@controlname='MyControl']"));

Re: Problem Splitting RxPath expressions

Posted: Wed Jan 16, 2013 4:06 pm
by Ciege
I agree with Alex... It *seems* that forms[0] does not contain the form you think it does...
Things I would try...

1) Run your code in debug. Put a breakpoint after you get the iList of Forms. Manually inspect the iList and check for what it contains.
2) Change from using an iList array to a single element variable so you don't ever have to worry in the future about hard coding the [0] item in that array... You never know if in the future you could run into a problem here.
3) Post a Ranorex snapshot of your AUT at this point where you are searching for the Form and Element.

Re: Problem Splitting RxPath expressions

Posted: Wed Jan 30, 2013 10:15 am
by jabelshauser
update to ranorex 4 -> ok