public bool ChooseOption(int order) { IElement buttonDropDown = GetDropDownButton(this); bool re = false; if (buttonDropDown == null) { re = this.Click(ClickOptions.RightElement); } else { re = buttonDropDown.Click(); } //Thread.Sleep(1000); var listOptions = GetListOptions(); if (listOptions == null) { GUI_Utils.AddNewActionReport(new ActionReport( "ChooseOption " + order + " of " + this.Attributes.Name + " fail", ActionReport.STATUS_FAILTURE, ActionReport.CATEGORY_PROCEDURE, Validate.CaptureScreen())); return(false); } re = re & ElementBase.Click(listOptions[order - 1]); return(re); }
public static bool NotExists(IElement element) { AutomationElement autoElement = GUI_Utils.SearchAutomationElement( new IdAndNameDesignCondition(element.Attributes.DesignedId, element.Attributes.DesignedName)); GUI_Utils.CheckRuntimeInstance(); string message = "Check NotExist of " + element.Attributes.Name; string status = ActionReport.STATUS_FAILTURE; string imgPath = null; bool check = (autoElement == null || autoElement.Current.IsOffscreen); if (check) { message += " successfully"; status = ActionReport.STATUS_SUCCESS; } else { message += " not successfully"; status = ActionReport.STATUS_FAILTURE; imgPath = CaptureScreen(); } GUI_Utils.AddNewActionReport(new ActionReport( message, status, ActionReport.CATEGORY_VALIDATION, imgPath)); return(check); }
public static bool TextNotContains(IElement element, string value) { // export report here string textAttribute = element.GetText(); if (textAttribute == null) { return(false); } string message = "Check " + element.Attributes.Name + "'s text not contains '" + value + "' is"; string status = ActionReport.STATUS_FAILTURE; string imgPath = null; bool check = !textAttribute.Contains(value); if (check) { message += " successful"; status = ActionReport.STATUS_SUCCESS; } else { message += " not successful"; status = ActionReport.STATUS_FAILTURE; imgPath = CaptureScreen(); } GUI_Utils.AddNewActionReport(new ActionReport( message, status, ActionReport.CATEGORY_VALIDATION, imgPath)); return(check); }
public static bool ExistsWithIdOnly(IElement element) { List <AutomationElement> autoElement = Search.SearchListAutomationElementsOnlyMatchId( element); string message = "Check ExistWidthIdOnly of " + element.Attributes.Name; string status = ActionReport.STATUS_FAILTURE; string imgPath = null; bool check = autoElement != null && autoElement.Count > 0; if (check) { message += " successfully"; status = ActionReport.STATUS_SUCCESS; } else { message += " not successfully"; status = ActionReport.STATUS_FAILTURE; imgPath = CaptureScreen(); } GUI_Utils.AddNewActionReport(new ActionReport( message, status, ActionReport.CATEGORY_VALIDATION, imgPath)); return(check); }
public static bool HeightEquals(IElement element, double value) { // export report here double realHeight = element.GetHeight(); string message = "Check " + element.Attributes.Name + "'s height equals with " + value + " is"; string status = ActionReport.STATUS_FAILTURE; string imgPath = null; bool check = realHeight == value; if (check) { message += " successful"; status = ActionReport.STATUS_SUCCESS; } else { message += " not successful"; status = ActionReport.STATUS_FAILTURE; imgPath = CaptureScreen(); } GUI_Utils.AddNewActionReport(new ActionReport( message, status, ActionReport.CATEGORY_VALIDATION, imgPath)); return(check); }
/// <summary> /// focus, then input normal string into this text element /// </summary> /// <param name="input"></param> /// <returns></returns> public bool InputString(string input) { AutomationElement element = GetCurrentAutoElement(); if (element == null) { GUI_Utils.AddNewActionReport(new ActionReport( "Input string '" + input + "' into " + this.Attributes.Name + " fail", ActionReport.STATUS_FAILTURE, ActionReport.CATEGORY_PROCEDURE, Validate.CaptureScreen())); return(false); } //element.SetFocus(); //ValuePattern valuePatternA = element.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; //valuePatternA.SetValue(input); object valuePattern = null; // Control does not support the ValuePattern pattern // so use keyboard input to insert content. // // NOTE: Elements that support TextPattern // do not support ValuePattern and TextPattern // does not support setting the text of // multi-line edit or document controls. // For this reason, text input must be simulated // using one of the following methods. // if (!element.TryGetCurrentPattern( ValuePattern.Pattern, out valuePattern)) { logger.Info("The control with an AutomationID of " + element.Current.AutomationId.ToString() + " does not support ValuePattern." + " Using keyboard input."); // Set focus for input functionality and begin. element.SetFocus(); // Pause before sending keyboard input. //Thread.Sleep(100); // Delete existing content in the control and insert new content. //SendKeys.SendWait("^{HOME}"); // Move to start of control //SendKeys.SendWait("^+{END}"); // Select everything //SendKeys.SendWait("{DEL}"); // Delete selection SendKeys.SendWait(input); Thread.Sleep(100); Keyboard.SendCombinedKeys(Keyboard.K_CTRL, Keyboard.K_END); } // Control supports the ValuePattern pattern so we can // use the SetValue method to insert content. else { logger.Info("The control with an AutomationID of " + element.Current.AutomationId.ToString() + " supports ValuePattern." + " Using ValuePattern.SetValue()."); // Set focus for input functionality and begin. element.SetFocus(); string old = ""; try { old = ((ValuePattern)valuePattern).Current.Value; } catch (Exception) { } ((ValuePattern)valuePattern).SetValue(old + input); Keyboard.SendCombinedKeys(Keyboard.K_CTRL, Keyboard.K_END); } return(true); }