/// <summary>
 ///     Builds the by.
 /// </summary>
 /// <returns>The value.</returns>
 public override By BuildBy()
 {
     if (HtmlElementUtils.IsHtmlElement(Property) || HtmlElementUtils.IsHtmlElementList(Property))
     {
         var type = HtmlElementUtils.IsHtmlElementList(Property)
                                 ? HtmlElementUtils.GetGenericParameterType(Property)
                                 : Property.PropertyType;
         return(BuildByFromHtmlElementAttributes(type));
     }
     return(base.BuildBy());
 }
Ejemplo n.º 2
0
 public override By BuildBy()
 {
     if (HtmlElementUtils.IsHtmlElement(Field) || HtmlElementUtils.IsHtmlElementList(Field))
     {
         Type type = HtmlElementUtils.IsHtmlElementList(Field) ? HtmlElementUtils.GetGenericParameterType(Field) : Field.FieldType;
         return(BuildByFromHtmlElementAttributes(type));
     }
     else
     {
         return(base.BuildBy());
     }
 }
        public override object Decorate(FieldInfo field)
        {
            //if (!IsDecoratableField(field))
            //{
            //    return null;
            //}

            IElementLocator locator = factory.CreateLocator(field);

            if (locator == null)
            {
                return(null);
            }

            String elementName = HtmlElementUtils.GetElementName(field);

            //if (HtmlElementUtils.IsTypifiedElement(field))
            //{
            Type typifiedElementType = field.FieldType;

            return(DecorateTypifiedElement(typifiedElementType, locator, elementName));

            //}
            if (HtmlElementUtils.IsHtmlElement(field))
            {
                Type htmlElementType = field.FieldType;
                return(DecorateHtmlElement(htmlElementType, locator, elementName));
            }
            else if (HtmlElementUtils.IsWebElement(field))
            {
                return(DecorateWebElement(locator, elementName));
            }
            //else if (HtmlElementUtils.IsTypifiedElementList(field))
            //{
            //    Type typifiedElementType = HtmlElementUtils.GetGenericParameterType(field);
            //    return DecorateTypifiedElementList(field.FieldType, typifiedElementType, locator, elementName);
            //}
            else if (HtmlElementUtils.IsHtmlElementList(field))
            {
                Type htmlElementType = HtmlElementUtils.GetGenericParameterType(field);
                return(DecorateHtmlElementList(field.FieldType, htmlElementType, locator, elementName));
            }
            else if (HtmlElementUtils.IsWebElementList(field))
            {
                return(DecorateWebElementList(locator, elementName));
            }

            return(null);
        }
        /// <summary>
        ///     Decorates the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <returns>The value.</returns>
        public override object Decorate(PropertyInfo propertyInfo)
        {
            if (!IsDecoratableProperty(propertyInfo))
            {
                return(null);
            }

            var locator = Factory.CreateLocator(propertyInfo);

            if (locator == null)
            {
                return(null);
            }

            var elementName = HtmlElementUtils.GetElementName(propertyInfo);

            if (HtmlElementUtils.IsTypifiedElement(propertyInfo))
            {
                var typifiedElementType = propertyInfo.PropertyType;
                return(DecorateTypifiedElement(typifiedElementType, locator, elementName));
            }
            if (HtmlElementUtils.IsHtmlElement(propertyInfo))
            {
                var htmlElementType = propertyInfo.PropertyType;
                return(DecorateHtmlElement(htmlElementType, locator, elementName));
            }
            if (HtmlElementUtils.IsWebElement(propertyInfo))
            {
                return(DecorateWebElement(locator, elementName));
            }
            if (HtmlElementUtils.IsTypifiedElementList(propertyInfo))
            {
                var typifiedElementType = HtmlElementUtils.GetGenericParameterType(propertyInfo);
                return(DecorateTypifiedElementList(propertyInfo.PropertyType, typifiedElementType, locator, elementName));
            }
            if (HtmlElementUtils.IsHtmlElementList(propertyInfo))
            {
                var htmlElementType = HtmlElementUtils.GetGenericParameterType(propertyInfo);
                return(DecorateHtmlElementList(propertyInfo.PropertyType, htmlElementType, locator, elementName));
            }
            if (HtmlElementUtils.IsWebElementList(propertyInfo))
            {
                return(DecorateWebElementList(locator, elementName));
            }

            return(null);
        }