Beispiel #1
0
        /// <summary>
        /// Factory of Locators based on the type of the IWebElement denoted by Enum id.
        /// </summary>
        /// <param name="id">The Enum identifier containing CSS of the target IWebElement.</param>
        /// <param name="parent">Locator of the parent IWebElement of the target IWebElement.</param>
        /// <returns>Locator with behaviore matched with the type of the element.</returns>
        public static Locator LocatorOf(Enum id, Fragment parent)
        {
            EnumMemberAttribute usage = EnumMemberAttribute.EnumMemberAttributeOf(id);

            switch (usage.TagName)
            {
            case HtmlTagName.Table:
                return(new TableLocator(id, parent));

            case HtmlTagName.Text:
                return(new TextLocator(id, parent));

            case HtmlTagName.Radio:
                return(new RadioLocator(id, parent));

            case HtmlTagName.Select:
                return(new SelectLocator(id, parent));

            case HtmlTagName.Checkbox:
            case HtmlTagName.Check:
                return(new CheckboxLocator(id, parent));

            default:
                return(new Locator(id, parent));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve the Index-th of the IWebElement collection located by collectionEnum.
        /// </summary>
        /// <param name="collectionEnum">The Enum identifier of a collection of IWebElement.</param>
        /// <param name="index">The Index number, from 0, of the concerned one within the collection.</param>
        /// <returns>The IWebElement whose order within the collection is identical to "Index".</returns>
        public IWebElement ElementByIndex(Enum collectionEnum, int index)
        {
            EnumMemberAttribute usage = EnumMemberAttribute.EnumMemberAttributeOf(collectionEnum);

            if (!usage.IsCollection)
            {
                throw new Exception(collectionEnum.ToString() + " shall be IsCollection=true.");
            }

            var thisElement = FindElement();
            var candidates  = thisElement.FindElementsByCss(usage.Css);

            return(candidates[index]);
        }
        public static string Value(this Enum theEnum)
        {
            if (EnumValues.ContainsKey(theEnum))
            {
                return(EnumValues[theEnum]);
            }

            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            if (!EnumValues.ContainsKey(theEnum))
            {
                EnumValues.Add(theEnum, memberAttribute.Value);
            }
            return(EnumValues[theEnum]);
        }
        public static string Css(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.Css);
        }
        public static bool IsCollection(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.IsCollection);
        }
        public static bool IsFragment(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.IsFragment);
        }
        public static string Description(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.Description);
        }
        public static Mechanisms Mechanism(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.Mechanism);
        }
        public static HtmlTagName TagName(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.TagName);
        }