public static void AutomationElementTryGetClickablePoint(AutomationElement element) { Dump("TryGetClickablePoint()", true, element); Point pt = new Point(); try { object obj = element.TryGetClickablePoint(out pt); } catch (Exception exception) { VerifyException(element, exception, typeof(ElementNotAvailableException)); } }
/// ------------------------------------------------------------------- /// <summary> /// Check the IsOffScreen property, and that FromPoint(pt) == element where point /// was obtained from TryClickablePoint /// </summary> /// ------------------------------------------------------------------- private void TS_VerifyElementIsOnScreenAndNotOverlapped(AutomationElement element, CheckType checkType) { if (true == element.Current.IsOffscreen) ThrowMe(checkType, "IsOffScreen == true"); Point pt = new Point(); if (false == element.TryGetClickablePoint(out pt)) ThrowMe(checkType, "TryGetClickablePoint() returned false"); if (false == Automation.Compare(element, AutomationElement.FromPoint(pt))) ThrowMe(checkType, "Could not get element from pt{0}, could the element be covered by another window?", pt); m_TestStep++; }
internal static bool TryGetClickablePoint(AutomationElement element, out Point point) { return element.TryGetClickablePoint(out point); }
/// <summary> /// This method will snap mouse cursor to element's clickable point. /// </summary> public void SnapMouseToClickablePoint(AutomationElement element) { Point clickablePoint; if (element.TryGetClickablePoint(out clickablePoint)) { this.Cursor = new Cursor(Cursor.Current.Handle); Cursor.Position = new System.Drawing.Point((int)clickablePoint.X, (int)clickablePoint.Y); } }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- internal void TSC_MouseClick(AutomationElement element, CheckType checkType) //Point pt, string varPt, CheckType ct) { Point pt = new Point(); if (!element.TryGetClickablePoint(out pt)) { ThrowMe(checkType, "TryGetClickablePoint returned false"); } Comment("Calling Performing mouse click @ Point(" + pt + ")"); ATGTestInput.Input.MoveToAndClick(pt); m_TestStep++; }