Exemplo n.º 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));
            }
        }
Exemplo n.º 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]);
        }
Exemplo n.º 3
0
        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]);
        }
Exemplo n.º 4
0
        public static string Css(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.Css);
        }
Exemplo n.º 5
0
        public static bool IsCollection(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.IsCollection);
        }
Exemplo n.º 6
0
        public static bool IsFragment(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.IsFragment);
        }
Exemplo n.º 7
0
        public static string Description(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.Description);
        }
Exemplo n.º 8
0
        public static Mechanisms Mechanism(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.Mechanism);
        }
Exemplo n.º 9
0
        public static HtmlTagName TagName(this Enum theEnum)
        {
            EnumMemberAttribute memberAttribute = EnumMemberAttribute.EnumMemberAttributeOf(theEnum);

            return(memberAttribute.TagName);
        }