Cannot find control by "FindControlName"

Ask general questions here.
wuyue0213
Posts: 3
Joined: Tue Sep 25, 2012 10:50 am

Cannot find control by "FindControlName"

Post by wuyue0213 » Tue Sep 25, 2012 10:55 am

Hi,

I encountered the problem intermittently. It seems that I can't find the control "TableLayoutPanel1" sometimes.. but once in a while it worked!

Can someone help me? Thanks very much!!!

Code: Select all

Private Sub TestButton()
		    Dim form As Form = Application.FindFormTitle("Log Viewer", SearchMatchMode.MatchFromStart)
			form.Activate()
			logger.Info("Logviewer form found!")
		
		    Dim tab As Integer = form.element.ChildCount
		    logger.Info(String.Format("{0} child found!",tab))
		
			form.Element.FindChild(Role.PushButton)
            logger.Info("Button found!")    

			Dim parent As Control = form.FindControlName("TableLayoutPanel1")
			logger.Info("Parent found!")
			
			Dim control As Control 
			Dim controlElement as Element
			control = parent.FindControlName("gridControlLogViewer")
			control.Focus()
			Logger.Info("User", "Get the accessibility element of the control.")
			controlElement = control.Element

			Dim element As Element
			element = controlElement.FindChild(Role.Cell)
			Logger.Info("User", "Click element 1 time(s) with right mouse button at offset = (500, 500).")
			Mouse.ClickElement(element, MouseButtonType.RightButton, New Point(500, 500), 1, 500)
			logger.Info("Test pass!")		
		End Sub

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Cannot find control by "FindControlName"

Post by Support Team » Tue Sep 25, 2012 3:03 pm

Hi,

Could it be that you are using Ranorex 1.X because the method is since Ranorex 2.X. no longer available.

Regards,
Markus
Ranorex Support Team

wuyue0213
Posts: 3
Joined: Tue Sep 25, 2012 10:50 am

Re: Cannot find control by "FindControlName"

Post by wuyue0213 » Thu Sep 27, 2012 7:31 am

Yes at first I'm using 1.5....
Thanks for your help!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Cannot find control by "FindControlName"

Post by Support Team » Thu Sep 27, 2012 4:48 pm

Hi,

I am glad I was able to help!
If you have any additional questions do not hesitate to contact us again.

Regards,
Markus
Ranorex Support Team