Page 1 of 1

FindSingle does not find element

Posted: Thu Mar 03, 2011 1:23 pm
by atom
Hiya

In Ranorex Spy I find the XPath to the element of interest
e.g.

/form[@title~'XtraGrid Features']/container[@controlname='panelControl1']/container[@controlname='gcContainer']/container[@controlname='Grid100000Records']/element[@controlname='gridControl1']

In my code if I do:

Dim myElement as Ranorex.Unknown = "... the string above ..."

Then the element is found instantly

However If i do:

Dim myForm as Ranorex.Form = "/form[@title~'XtraGrid Features']"
Dim myElement as Ranorex.Unknown = myForm.FindSingle(of ranorex.unknown)("container[@controlname='panelControl1']/container[@controlname='gcContainer']/container[@controlname='Grid100000Records']/element[@controlname='gridControl1']")

Then it does not find the element
Any clues why?

Re: FindSingle does not find element

Posted: Thu Mar 03, 2011 1:45 pm
by Support Team
atom wrote:Any clues why?
The first thing that comes to my mind is that there are two forms with a title containing the string 'XtraGrid Features' and the second form is the right one. Consequently, with the full path the correct form is used. If you search the form first and then use relative paths, the wrong form is searched.

Could that be the issue?

Regards,
Alex
Ranorex Team

Re: FindSingle does not find element

Posted: Thu Mar 03, 2011 2:21 pm
by atom
Hiya

I checked theres no other forms matching that title

Re: FindSingle does not find element

Posted: Thu Mar 03, 2011 2:26 pm
by Support Team
The only other thing I could imagine is that the 'gridControl1' is not yet loaded when the form is found and searched. Consequently, the search will fail as you have not specified a timeout for the search, thus the whole form will be only searched once. In contrast, when you assign a path directly to an adapter, the Adapter.DefaultSearchTimeout is used.

Try specifying a timeout for the FindSingle method.

Regards,
Alex
Ranorex Team

Re: FindSingle does not find element

Posted: Thu Mar 03, 2011 2:27 pm
by atom
Sorry - was a silly mistake i was doing!
Its ok now!