コード例 #1
0
        /// <summary>
        /// Selects an item if not already selected.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="stringComparison"></param>
        public virtual void SelectItem(string item,
                                       StringComparison stringComparison = StringComparison.Ordinal)
        {
            var isAlreadySelected = GetSelectedOptions()
                                    .Any(opt => String.Equals(
                                             opt,
                                             item,
                                             stringComparison));

            if (isAlreadySelected)
            {
                return;
            }

            Expand();

            var el = OptionElements.FirstOrDefault(
                e => String.Equals(
                    e.TextHelper().InnerText,
                    item,
                    stringComparison));

            // Throw if the element doesn't exist.
            if (el == null)
            {
                throw new NoSuchElementException();
            }

            // Use keyboard or mouse depending on config.
            if (configuration.ControlWithKeyboardInsteadOfMouse)
            {
                el.SendKeys(Keys.Enter);
            }
            else
            {
                el.Click();
            }

            if (configuration.AutoClose)
            {
                // Wait until the dropdown is hidden.
                WrappedDriver
                .Wait(animationData.AnimationDuration)
                .Until(d => !el.Displayed);
            }

            // Wait until the new item is present in the list.
            WrappedDriver
            .Wait(animationData.AnimationDuration)
            .Until(
                d => GetSelectedOptions().Any(
                    opt => String.Equals(opt, item, stringComparison)));
        }
コード例 #2
0
        /// <summary>
        /// Gets a value indicating whether an unknown element is encountered during deserialization.
        /// To keep compatible with old configuration
        /// </summary>
        /// <param name="elementName">The name of the unknown subelement.</param>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> being used for deserialization.</param>
        /// <returns>
        /// true when an unknown element is encountered while deserializing; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.Configuration.ConfigurationErrorsException">The element identified by <paramref name="elementName"/> is locked.- or -One or more of the element's attributes is locked.- or -<paramref name="elementName"/> is unrecognized, or the element has an unrecognized attribute.- or -The element has a Boolean attribute with an invalid value.- or -An attempt was made to deserialize a property more than once.- or -An attempt was made to deserialize a property that is not a valid member of the element.- or -The element cannot contain a CDATA or text element.</exception>
        protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
        {
            //To keep compatible with old configuration
            if (!"services".Equals(elementName, StringComparison.OrdinalIgnoreCase))
            {
                if (OptionElements == null)
                {
                    OptionElements = new NameValueCollection();
                }

                OptionElements.Add(elementName, reader.ReadOuterXml());
                return(true);
            }

            var serverTypes = new TypeProviderCollection();

            reader.Read();
            serverTypes.Deserialize(reader);

            this["serverTypes"] = serverTypes;

            return(true);
        }
コード例 #3
0
 /// <summary>
 /// Returns a list of all options.
 /// </summary>
 /// <returns></returns>
 public virtual IEnumerable <string> GetAllOptions()
 {
     return(OptionElements.Select(e => e.TextHelper().InnerText));
 }