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