Ranorex can't find elements during execution

Ask general questions here.
mirih87
Posts: 11
Joined: Tue Jul 08, 2014 1:54 pm

Ranorex can't find elements during execution

Post by mirih87 » Sun Jul 27, 2014 3:49 pm

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

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Ranorex can't find elements during execution

Post by testautomator » Mon Jul 28, 2014 5:47 am

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?

mirih87
Posts: 11
Joined: Tue Jul 08, 2014 1:54 pm

Re: Ranorex can't find elements during execution

Post by mirih87 » Mon Jul 28, 2014 8:00 am

My error is "Failed to find item ..."

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

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Ranorex can't find elements during execution

Post by testautomator » Mon Jul 28, 2014 8:20 am

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.

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Ranorex can't find elements during execution

Post by mzperix » Thu Jul 31, 2014 11:29 am

Also, you can create a snapshot runtime about the parent elements, so you can analyze what does ranorex see on runtime.