FindSingle does not find element

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

FindSingle does not find element

Post by atom » Thu Mar 03, 2011 1:23 pm

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?

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

Re: FindSingle does not find element

Post by Support Team » Thu Mar 03, 2011 1:45 pm

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

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: FindSingle does not find element

Post by atom » Thu Mar 03, 2011 2:21 pm

Hiya

I checked theres no other forms matching that title

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

Re: FindSingle does not find element

Post by Support Team » Thu Mar 03, 2011 2:26 pm

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

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: FindSingle does not find element

Post by atom » Thu Mar 03, 2011 2:27 pm

Sorry - was a silly mistake i was doing!
Its ok now!