Problem Splitting RxPath expressions

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Problem Splitting RxPath expressions

Post by jabelshauser » Tue Jan 15, 2013 1:27 pm

"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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Problem Splitting RxPath expressions

Post by Ciege » Tue Jan 15, 2013 10:20 pm

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?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Re: Problem Splitting RxPath expressions

Post by jabelshauser » Wed Jan 16, 2013 7:52 am

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

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

Re: Problem Splitting RxPath expressions

Post by Support Team » Wed Jan 16, 2013 10:09 am

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

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Re: Problem Splitting RxPath expressions

Post by jabelshauser » Wed Jan 16, 2013 10:31 am

- 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']"));

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Problem Splitting RxPath expressions

Post by Ciege » Wed Jan 16, 2013 4:06 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Re: Problem Splitting RxPath expressions

Post by jabelshauser » Wed Jan 30, 2013 10:15 am

update to ranorex 4 -> ok