예제 #1
0
        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;
        }
예제 #2
0
        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);
        }
예제 #3
0
        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");
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
 /// <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));
     }
 }
예제 #8
0
        /// <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);
        }
예제 #9
0
        /// <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);
        }
예제 #10
0
        /// <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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        /// <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);
        }
예제 #13
0
        /// <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);
            }
        }
예제 #14
0
        /// <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);
            }
        }