public void ScrollAndClick <T>(UITestControl parent, PropertyType type, string typeC) where T : HtmlControl { HtmlControl control = (T)Activator.CreateInstance(typeof(T), new object[] { parent }); AddPropertyControl(control, type, typeC); bool isClickable = false; if (control.TryFind()) { while (!isClickable) { try { control.EnsureClickable(); Mouse.Click(control); isClickable = true; } catch (FailedToPerformActionOnHiddenControlException) { Mouse.MoveScrollWheel(-1); throw; } } } else { throw new AssertInconclusiveException("Control Not Found"); } }
/// <summary> /// Clicks the element. /// </summary> /// <param name="element">The element.</param> /// <returns><c>true</c> unless there is an error.</returns> public override bool ClickElement(HtmlControl element) { Point point; if (element.TryGetClickablePoint(out point)) { element.EnsureClickable(); } Mouse.Click(element); return(true); }
/// <summary> /// Clicks the element. /// </summary> /// <param name="element">The element.</param> /// <returns><c>true</c> unless there is an error.</returns> public override bool ClickElement(HtmlControl element) { this.WaitForElement(element, WaitConditions.NotMoving, timeout: null); Point point; if (element.TryGetClickablePoint(out point)) { element.EnsureClickable(); } Mouse.Click(element); return(true); }
public static bool IsElementVisible(this HtmlControl control) { // Assume the control is invisible bool visible = false; System.Drawing.Point p; try { // If the control is offscreen, bring it into the viewport control.EnsureClickable(); // Now check the coordinates of the clickable point visible = control.TryGetClickablePoint(out p) && (p.X > 0 || p.Y > 0); } catch (Exception ex) { // Boom goes the dynamite! Control is not visible. // Log to stdout for debugging. Console.WriteLine(ex); } return(visible); }