public PropertyExpressionCollection ToPropertyCollection( ) { var resultCollection = new PropertyExpressionCollection(); var type = typeof(WebControl); var properties = type.GetProperties(); var propertyValue = string.Empty; foreach (var property in properties) { propertyValue = property.GetValue(this, null) as string; if (!string.IsNullOrWhiteSpace(propertyValue)) { if (propertyValue.Contains('*')) { propertyValue = propertyValue.Replace("*", string.Empty); resultCollection.Add(property.Name, propertyValue, PropertyExpressionOperator.Contains); } else { resultCollection.Add(property.Name, propertyValue, PropertyExpressionOperator.EqualTo); } } } return resultCollection; }
public PropertyExpressionCollection ToPropertyCollection() { var resultCollection = new PropertyExpressionCollection(); var type = typeof(SearchSelector); var properties = type.GetProperties(); var propertyValue = string.Empty; foreach (var property in properties) { propertyValue = property.GetValue(this) as string; if (!string.IsNullOrWhiteSpace(propertyValue)) { if (propertyValue.Contains('*')) { propertyValue = propertyValue.Replace("*", string.Empty); resultCollection.Add(property.Name, propertyValue, PropertyExpressionOperator.Contains); } else { resultCollection.Add(property.Name, propertyValue, PropertyExpressionOperator.EqualTo); } } } return(resultCollection); }
public static void ClickDisplayButton(string name) { ApplicationUnderTest messageBox = new ApplicationUnderTest(); PropertyExpressionCollection properties = new PropertyExpressionCollection(); properties.Add(UITestControl.PropertyNames.TechnologyName, MSAA_TECHNOLOGY); properties.Add(UITestControl.PropertyNames.ControlType, "Window"); }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) throw new ArgumentNullException("searchProperties"); searchProperties.Add(HtmlControl.PropertyNames.TagName, tagName, conditionOperator); }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) throw new ArgumentNullException("searchProperties"); searchProperties.Add(WpfControl.PropertyNames.AutomationId, automationId, conditionOperator); }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) throw new ArgumentNullException("searchProperties"); searchProperties.Add(this.propertyName, this.propertyValue, this.conditionOperator); }
/// <summary> /// Sets the property. /// </summary> /// <param name="collection">The collection.</param> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <param name="propertyExpressionOperator">The property expression operator.</param> private static void SetProperty(PropertyExpressionCollection collection, string key, string value, PropertyExpressionOperator propertyExpressionOperator) { if (!string.IsNullOrWhiteSpace(value)) { collection.Add(new PropertyExpression(key, value, propertyExpressionOperator)); } }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) { throw new ArgumentNullException("searchProperties"); } searchProperties.Add(HtmlControl.PropertyNames.ValueAttribute, valueAttribute, conditionOperator); }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) { throw new ArgumentNullException("searchProperties"); } searchProperties.Add(WpfControl.PropertyNames.AutomationId, automationId, conditionOperator); }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) { throw new ArgumentNullException("searchProperties"); } searchProperties.Add(this.propertyName, this.propertyValue, this.conditionOperator); }
public static void AddUpdateSearchProperties(UITestControl control, Dictionary <string, string> propertyDict) { PropertyExpressionCollection expCollection = new PropertyExpressionCollection(); foreach (KeyValuePair <string, string> propValue in propertyDict) { expCollection.Add(propValue.Key, propValue.Value); } control.SearchProperties.AddRange(expCollection); }
/// <summary> /// Click the specific messagebox button /// </summary> /// <param name="buttonName">The messagebox button's name</param> /// <param name="title">The messagebox's title</param> /// <exception cref="Exception">If the control is not found</exception> public static void ClickMessageBoxButton(string title, string buttonName) { ApplicationUnderTest messageBox = new ApplicationUnderTest(); PropertyExpressionCollection properties = new PropertyExpressionCollection(); properties.Add(UITestControl.PropertyNames.TechnologyName, MSAA_TECHNOLOGY); properties.Add(UITestControl.PropertyNames.ControlType, "Window"); properties.Add(UITestControl.PropertyNames.Name, title); messageBox.SearchProperties.AddRange(properties); messageBox.Find(); UITestControl button = new UITestControl(messageBox); PropertyExpressionCollection properties2 = new PropertyExpressionCollection(); properties2.Add(UITestControl.PropertyNames.TechnologyName, MSAA_TECHNOLOGY); properties2.Add(UITestControl.PropertyNames.ControlType, "Button"); properties2.Add(UITestControl.PropertyNames.Name, buttonName); button.SearchProperties.AddRange(properties2); button.Find(); Mouse.Click(button); }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> /// <exception cref="InvalidSearchPropertiesFormatException"> /// Format of search properties is invalid. /// </exception> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) { throw new ArgumentNullException("searchProperties"); } // Split on groups of name/value pairs string[] nameValuePairs = this.searchProperties.Split( new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string nameValuePair in nameValuePairs) { var compareOperator = PropertyExpressionOperator.EqualTo; // If split on '=' does not work, then try '~' // Split at the first instance of '='. Other instances are considered part of the value. string[] splittedNameValuePair = nameValuePair.Split( new[] { '=' }, 2); if (splittedNameValuePair.Length != 2) { // Otherwise try to split on '~'. If it works then compare type is Contains // Split at the first instance of '~'. Other instances are considered part of the value. splittedNameValuePair = nameValuePair.Split( new[] { '~' }, 2); if (splittedNameValuePair.Length == 2) { compareOperator = PropertyExpressionOperator.Contains; } else { throw new InvalidSearchPropertiesFormatException(this.searchProperties); } } // Add the search property, value and type searchProperties.Add(splittedNameValuePair[0], splittedNameValuePair[1], compareOperator); } }
/// <summary> /// Configures the specified search properties. /// </summary> /// <param name="searchProperties">The search properties.</param> /// <exception cref="InvalidSearchPropertiesFormatException"> /// Format of search properties is invalid. /// </exception> public void Configure(PropertyExpressionCollection searchProperties) { if (searchProperties == null) throw new ArgumentNullException("searchProperties"); // Split on groups of name/value pairs string[] nameValuePairs = this.searchProperties.Split( new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string nameValuePair in nameValuePairs) { var compareOperator = PropertyExpressionOperator.EqualTo; // If split on '=' does not work, then try '~' // Split at the first instance of '='. Other instances are considered part of the value. string[] splittedNameValuePair = nameValuePair.Split( new[] { '=' }, 2); if (splittedNameValuePair.Length != 2) { // Otherwise try to split on '~'. If it works then compare type is Contains // Split at the first instance of '~'. Other instances are considered part of the value. splittedNameValuePair = nameValuePair.Split( new[] { '~' }, 2); if (splittedNameValuePair.Length == 2) { compareOperator = PropertyExpressionOperator.Contains; } else { throw new InvalidSearchPropertiesFormatException(this.searchProperties); } } // Add the search property, value and type searchProperties.Add(splittedNameValuePair[0], splittedNameValuePair[1], compareOperator); } }