Page 1 of 1

Ranorex can't find elements during execution

Posted: Sun Jul 27, 2014 3:49 pm
by mirih87
Ranorex can't find elements during execution although Ranorex spy find them.

My RanorexPath:
.//tr[@id~'ctl00_cphMain_MyReport1_GridReport_ctl00__[0-9]']/td[4]/a[@innertext='Paste Content']/../../td[7]/a[@innertext=$filename]/../..//td[3]

Please assist.
Thanks in advance

Re: Ranorex can't find elements during execution

Posted: Mon Jul 28, 2014 5:47 am
by testautomator
Hi,
Maybe you can test the path by going one level at a time during runtime.
Try a code like this, Myobject().MoveTo(). And keep changing MyObjects path and change its adapter type as and when required. Its definitely path issue.
What is the error message?

Re: Ranorex can't find elements during execution

Posted: Mon Jul 28, 2014 8:00 am
by mirih87
My error is "Failed to find item ..."

Can You write an example for the code you mentioned before?
thanks

Re: Ranorex can't find elements during execution

Posted: Mon Jul 28, 2014 8:20 am
by testautomator
This is your original path:
.//tr[@id~'ctl00_cphMain_MyReport1_GridReport_ctl00__[0-9]']/td[4]/a[@innertext='Paste Content']/../../td[7]/a[@innertext=$filename]/../..//td[3]

Now lets see if we can go to td[4]:
TdTag TempObj = yourdome + ".//tr[@id~'ctl00_cphMain_MyReport1_GridReport_ctl00__[0-9]']/td[4]";
TempObj().MoveTo();

If this works, the mouse moves to that location then we are good. If not fix the path.
Now lets see if we can go to td[7]:
TdTag TempObj = yourdome + ".//tr[@id~'ctl00_cphMain_MyReport1_GridReport_ctl00__[0-9]']/td[4]/a[@innertext='Paste Content']/../../td[7]";
TempObj().MoveTo();

If this works, the mouse moves to that location then we are good. If not fix the path.

Now lets see if we can go to a[@innertext=$filename]:
ATag TempObj = yourdome + ".//tr[@id~'ctl00_cphMain_MyReport1_GridReport_ctl00__[0-9]']/td[4]/a[@innertext='Paste Content']";
TempObj().MoveTo();

Like this you have to confirm your xpaths. Remember, dont run these lines all at once. Keep changing the TempObj type and try.

The best way is to build your xpath on the spy itself. But you said it works there and not in the script. It cannot actually happen that way. Just make sure spy is stopping at the correct object. It usually stops at the last object it finds and not the object you wanted it to. If not sure use the 'Highlight Element' option in the right click.

Re: Ranorex can't find elements during execution

Posted: Thu Jul 31, 2014 11:29 am
by mzperix
Also, you can create a snapshot runtime about the parent elements, so you can analyze what does ranorex see on runtime.