/// <summary> /// Waits for element. /// </summary> /// <param name="element">The element.</param> /// <param name="waitCondition">The wait condition.</param> /// <param name="timeout">The timeout to wait before failing.</param> /// <returns><c>true</c> if the condition is met, <c>false</c> otherwise.</returns> public override bool WaitForElement(HtmlControl element, WaitConditions waitCondition, TimeSpan?timeout) { var milliseconds = (int)timeout.GetValueOrDefault(TimeSpan.FromSeconds(10)).TotalMilliseconds; switch (waitCondition) { case WaitConditions.Exists: return(element.WaitForControlExist(milliseconds)); case WaitConditions.NotExists: return(element.WaitForControlNotExist(milliseconds)); case WaitConditions.Enabled: return(element.WaitForControlCondition(e => e.Enabled, milliseconds)); case WaitConditions.NotEnabled: return(element.WaitForControlCondition(e => !e.Enabled, milliseconds)); case WaitConditions.NotMoving: element.WaitForControlExist(milliseconds); return(element.WaitForControlCondition(e => !this.Moving(e), milliseconds)); } return(true); }
//Generic Function to click Button, Image or Link public static bool WaitForItemExist <T>(PropertyType type, string propertyValue) where T : HtmlControl { HtmlControl genericControl = (T)Activator.CreateInstance(typeof(T), new object[] { ParentWindow }); if (type == PropertyType.Name) { genericControl.SearchProperties[HtmlControl.PropertyNames.Name] = propertyValue; } else if (type == PropertyType.ID) { genericControl.SearchProperties[HtmlControl.PropertyNames.Id] = propertyValue; } else if (type == PropertyType.InnerText) { genericControl.SearchProperties[HtmlControl.PropertyNames.InnerText] = propertyValue; } if (genericControl.WaitForControlExist(GlbVar.WAIT_TIME)) { return(true); } else { return(false); } }
public void HoverInMenu <T>(UITestControl parent, PropertyType type, string typeC) where T : HtmlControl { HtmlControl control = (T)Activator.CreateInstance(typeof(T), new object[] { parent }); AddPropertyControl(control, type, typeC); control.WaitForControlExist(); Mouse.HoverDuration = 1000; Mouse.Hover(control); }
public bool IsFormValuesCorrect() { HtmlControl datePicker = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UIDateEdit; string datePickerValue = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UIDateEdit.Text; datePicker.WaitForControlExist(); datePicker.DrawHighlight(); if (datePickerValue != DateTime.Now.ToString("M/dd/yyyy")) { return(false); } HtmlControl number = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UINumberEdit; string numberValue = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UINumberEdit.Text; number.DrawHighlight(); if (numberValue != DateTime.Now.ToString("M/dd/yyyy")) { return(false); } HtmlControl subject = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UISubjectEdit; string subjectValue = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UISubjectEdit.Text; subject.DrawHighlight(); if (subjectValue != DateTime.Now.ToString("M/dd/yyyy")) { return(false); } HtmlControl location = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UILocationEdit; string locationValue = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UILocationEdit.Text; location.DrawHighlight(); if (locationValue != DateTime.Now.ToString("M/dd/yyyy")) { return(false); } HtmlControl assignUser = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UIUserList1_1Custom.UIItemEdit; string assignUserValue = this.UIFormDetailsInternetEWindow.UIFormDetailsDocument.UIUserList1_1Custom.UIItemEdit.Text; assignUser.DrawHighlight(); if (assignUserValue != "Rugile Petrukauskaite") { return(false); } return(true); }
/// <summary> /// Clicks available control /// </summary> /// <param name="viewName">from control.xml</param> /// <param name="controlName">from control.xml</param> /// <param name="waitTime"></param> /// <param name="dynamicVariable"></param> public static void Click(string viewName, string controlName, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "") { Control control = PopulateControl(viewName, controlName, dynamicVariable); Logger.InsertLogLine("Click on control: " + control.ControlName + " in View : " + viewName); if (control.ControlZone == "Native") { xamlControl = GetXamlControl(control, dynamicVariable, waitTime); xamlControl.WaitForControlExist(waitTime); Gesture.Tap(new Point(xamlControl.BoundingRectangle.X + xamlControl.BoundingRectangle.Width / 2, xamlControl.BoundingRectangle.Y + xamlControl.BoundingRectangle.Height / 2)); } else if (control.ControlZone == "Web") { htmlControl = GetHtmlControl(control, dynamicVariable, waitTime); htmlControl.WaitForControlExist(waitTime); Gesture.Tap(new Point(htmlControl.BoundingRectangle.X + htmlControl.BoundingRectangle.Width / 2, htmlControl.BoundingRectangle.Y + htmlControl.BoundingRectangle.Height / 2)); //Gesture.Tap(htmlControl); } else if (control.ControlZone == "DirectUI") { directUIControl = GetDirectUIControl(control, dynamicVariable, waitTime); Gesture.Tap(directUIControl); } }