private static object CreateProxyObject(Type memberType, IElementLocator locator, IEnumerable <By> bys, bool cache)
        {
            object proxyObject = null;

            if (memberType == typeof(IList <IWebElement>))
            {
                foreach (var type in InterfacesToBeProxied)
                {
                    Type listType = typeof(IList <>).MakeGenericType(type);
                    if (listType.Equals(memberType))
                    {
                        proxyObject = WebElementListProxy.CreateProxy(memberType, locator, bys, cache);
                        break;
                    }
                }
            }
            else if (memberType == typeof(IWebElement))
            {
                proxyObject = WebElementProxy.CreateProxy(InterfaceProxyType, locator, bys, cache);
            }
            else
            {
                throw new ArgumentException("Type of member '" + memberType.Name + "' is not IWebElement or IList<IWebElement>");
            }

            return(proxyObject);
        }
Exemplo n.º 2
0
        private static object CreateProxyObject(Type memberType, IElementLocator locator, IEnumerable <By> bys, bool cache)
        {
            object result = null;

            if (memberType == typeof(IList <IWebElement>))
            {
                using (List <Type> .Enumerator enumerator = DefaultPageObjectMemberDecorator.InterfacesToBeProxied.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Type current = enumerator.Current;
                        Type type    = typeof(IList <>).MakeGenericType(new Type[]
                        {
                            current
                        });
                        if (type.Equals(memberType))
                        {
                            result = WebElementListProxy.CreateProxy(memberType, locator, bys, cache);
                            break;
                        }
                    }
                    return(result);
                }
            }
            if (!(memberType == typeof(IWebElement)))
            {
                throw new ArgumentException("Type of member '" + memberType.Name + "' is not IWebElement or IList<IWebElement>");
            }
            result = WebElementProxy.CreateProxy(DefaultPageObjectMemberDecorator.InterfaceProxyType, locator, bys, cache);
            return(result);
        }
Exemplo n.º 3
0
        private static object CreateProxyObject(Type memberType, ISearchContext driver, List <By> bys, bool cache, IElementLocatorFactory locatorFactory)
        {
            object proxyObject = null;

            if (memberType == typeof(IList <IWebElement>))
            {
                proxyObject = new WebElementListProxy(driver, bys, cache, locatorFactory);
            }
            else if (memberType == typeof(IWebElement))
            {
                proxyObject = new WebElementProxy(driver, bys, cache, locatorFactory);
            }

            return(proxyObject);
        }