private HtmlElementListNamedProxyHandler(Type elementType, IElementLocator locator, string name) : base() { this.elementType = elementType; this.locator = locator; this.name = name; }
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); }
public object Decorate(MemberInfo member, IElementLocator locator) { var customizedResult = new DefaultPageObjectMemberDecorator().Decorate(member, locator); if (customizedResult != null) { return(customizedResult); } var property = member as PropertyInfo; if (property == null || !property.CanWrite || !property.GetMethod.IsPublic) { return(null); } var bys = new List <By> { By.Id(member.Name), new OrbitButtonLocator(member.Name), new OrbitTableFieldLocator(member.Name) }; bool cache = ShouldCacheLookup(member); return(CreateProxyObject(property.PropertyType, locator, bys, cache)); }
public U GetChildNodeByText <U>(T node, IElementLocator childrenLocator, string regex) where U : WebControl, IElement { var children = new ListElement <U>(this.browser, node, childrenLocator); return(children.GetElementByText(regex)); }
public static T CreateControl <T>(IElement?parent, IElementLocator elementLocator) where T : class, IElement { var control = Activator.CreateInstance(typeof(T), parent, elementLocator) as T; return(Browser.Instance.CreateControl <T>(control)); }
/// <summary> /// Locates an element or list of elements for a Page Object member, and returns a /// proxy object for the element or list of elements. /// </summary> /// <param name="member">The <see cref="MemberInfo"/> containing information about /// a class's member.</param> /// <param name="locator">The <see cref="IElementLocator"/> used to locate elements.</param> /// <returns>A transparent proxy to the WebDriver element object.</returns> public virtual object?Decorate(MemberInfo member, IElementLocator locator) { FieldInfo? field = member as FieldInfo; PropertyInfo?property = member as PropertyInfo; Type?targetType = null; if (field != null) { targetType = field.FieldType; } if (property != null && property.CanWrite) { targetType = property.PropertyType; } if (targetType == null) { return(null); } IList <By> bys = CreateLocatorList(member); if (bys.Count > 0) { bool cache = ShouldCacheLookup(member); return(CreateObject(targetType, locator, bys, cache)); } return(null); }
public ElementBase(IBrowser browser, IElement parent, IElementLocator locator) { this.browser = browser; this.parent = parent; this.locator = locator; this.rootElement = WebElement.Create(browser, parent, locator); }
internal static Func <IElementLocator, ReadOnlyCollection <IWebElement> > ReturnWaitingFunction( IElementLocator locator, IEnumerable <By> bys) { return((IElementLocator) => { List <IWebElement> result = new List <IWebElement>(); foreach (var by in bys) { try { List <By> listOfSingleBy = new List <By>(); listOfSingleBy.Add(by); result.AddRange(locator.LocateElements(listOfSingleBy)); } catch (NoSuchElementException e) { continue; } catch (Exception e) { throw e; } } if (result.Count > 0) { return result.AsReadOnly(); } return null; }); }
/// <summary> /// Initializes a new instance of the <see cref="WebDriverObjectProxy"/> class. /// </summary> /// <param name="classToProxy">The <see cref="Type"/> of object for which to create a proxy.</param> /// <param name="locator">The <see cref="IElementLocator"/> implementation that /// determines how elements are located.</param> /// <param name="bys">The list of methods by which to search for the elements.</param> /// <param name="cache"><see langword="true"/> to cache the lookup to the element; otherwise, <see langword="false"/>.</param> protected WebDriverObjectProxy(Type classToProxy, IElementLocator locator, IEnumerable<By> bys, bool cache) : base(classToProxy) { this.locator = locator; this.bys = bys; this.cache = cache; }
/// <summary> /// Initializes the elements in the Page Object with the given type. /// </summary> /// <typeparam name="T">The <see cref="Type"/> of the Page Object class.</typeparam> /// <param name="locator">The <see cref="IElementLocator"/> implementation that /// determines how elements are located.</param> /// <returns>An instance of the Page Object class with the elements initialized.</returns> /// <remarks> /// The class used in the <typeparamref name="T"/> argument must have a public constructor /// that takes a single argument of type <see cref="IWebDriver"/>. This helps to enforce /// best practices of the Page Object pattern, and encapsulates the driver into the Page /// Object so that it can have no external WebDriver dependencies. /// </remarks> /// <exception cref="ArgumentException"> /// thrown if no constructor to the class can be found with a single IWebDriver argument /// <para>-or-</para> /// if a field or property decorated with the <see cref="FindsByAttribute"/> is not of type /// <see cref="IWebElement"/> or IList{IWebElement}. /// </exception> public static T InitElements <T>(IElementLocator locator) { T page = default(T); Type pageClassType = typeof(T); ConstructorInfo ctor = pageClassType.GetConstructor(new Type[] { typeof(IWebDriver) }); if (ctor == null) { throw new ArgumentException("No constructor for the specified class containing a single argument of type IWebDriver can be found"); } if (locator == null) { throw new ArgumentNullException("locator", "locator cannot be null"); } IWebDriver driver = locator.SearchContext as IWebDriver; if (driver == null) { throw new ArgumentException("The search context of the element locator must implement IWebDriver", "locator"); } page = (T)ctor.Invoke(new object[] { locator.SearchContext as IWebDriver }); InitElements(page, locator); return(page); }
/// <summary> /// Initializes a new instance of the <see cref="WebDriverObjectProxy"/> class. /// </summary> /// <param name="classToProxy">The <see cref="Type"/> of object for which to create a proxy.</param> /// <param name="locator">The <see cref="IElementLocator"/> implementation that /// determines how elements are located.</param> /// <param name="bys">The list of methods by which to search for the elements.</param> /// <param name="cache"><see langword="true"/> to cache the lookup to the element; otherwise, <see langword="false"/>.</param> protected WebDriverObjectProxy(Type classToProxy, IElementLocator locator, IEnumerable <By> bys, bool cache) : base(classToProxy) { this.locator = locator; this.bys = bys; this.cache = cache; }
private static object CreateProxyObject(Type memberType, IElementLocator locator, IEnumerable <By> bys, bool cache) { var dynMethod = typeof(DefaultPageObjectMemberDecorator).GetMethod("CreateProxyObject", BindingFlags.NonPublic | BindingFlags.Static); var isWebElement = memberType == typeof(IList <IWebElement>) || memberType == typeof(IWebElement); var proxyObject = dynMethod.Invoke(null, new object[] { isWebElement?memberType: typeof(IWebElement), locator, bys, cache }); if (!isWebElement) { // see if the type has a constructor that takes an instance of IWebElement. If so, // create an instance of the type and feed it the generated proxy object. var ctor = memberType.GetConstructor(new[] { typeof(IWebElement) }); if (ctor == null) { throw new ArgumentException( "No constructor for the specified class containing a single argument of type IWebDriver can be found"); } return(ctor.Invoke(new[] { proxyObject })); } return(proxyObject); }
public static T InitElements <T>(IElementLocator locator) { T t = default(T); Type typeFromHandle = typeof(T); ConstructorInfo constructor = typeFromHandle.GetConstructor(new Type[] { typeof(IWebDriver) }); if (constructor == null) { throw new ArgumentException("No constructor for the specified class containing a single argument of type IWebDriver can be found"); } if (locator == null) { throw new ArgumentNullException("locator", "locator cannot be null"); } if (!(locator.SearchContext is IWebDriver)) { throw new ArgumentException("The search context of the element locator must implement IWebDriver", "locator"); } t = (T)((object)constructor.Invoke(new object[] { locator.SearchContext as IWebDriver })); PageFactory.InitElements(t, locator); return(t); }
public virtual object Decorate(FieldInfo field) { if (!(typeof(IWebElement).IsAssignableFrom(field.FieldType) || IsDecoratableList(field))) { return(null); } IElementLocator locator = factory.CreateLocator(field); if (locator == null) { return(null); } if (typeof(IWebElement).IsAssignableFrom(field.FieldType)) { return(ProxyForLocator(locator)); } else if (typeof(IList).IsAssignableFrom(field.FieldType)) { return(ProxyForListLocator(locator)); } else { return(null); } }
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 = CustomPageObjectMemberDecorator.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(CustomPageObjectMemberDecorator.InterfaceProxyType, locator, bys, cache); return(result); }
private static object NewElement(Type type, IElementLocator locator, bool cache) { var proxy = GenerateProxy(typeof(IHtmlElement), new ElementProxy(locator, cache)) as IHtmlElement; return(type == typeof(IHtmlElement) || type == typeof(IWebElement) ? new HtmlElement(proxy) : ObjectFactory.Create(type, proxy)); }
// // Methods // public object Decorate(MemberInfo member, IElementLocator locator) { FieldInfo fieldInfo = member as FieldInfo; PropertyInfo propertyInfo = member as PropertyInfo; Type memberType = null; if (fieldInfo != null) { memberType = fieldInfo.FieldType; } bool flag = false; if (propertyInfo != null) { flag = propertyInfo.CanWrite; memberType = propertyInfo.PropertyType; } if (fieldInfo == null & (propertyInfo == null || !flag)) { return(null); } IList <By> list = CustomPageObjectMemberDecorator.CreateLocatorList(member); if (list.Count > 0) { bool cache = CustomPageObjectMemberDecorator.ShouldCacheLookup(member); return(CustomPageObjectMemberDecorator.CreateProxyObject(memberType, locator, list, cache)); } return(null); }
public TestHandler(IElementLocator elementLocator, IWebElement testElement, int testIndex) { this._elementLocator = elementLocator; this._testElement = testElement; this._testIndex = testIndex; Console.ForegroundColor = OutputColor; }
internal static Func<IElementLocator, ReadOnlyCollection<IWebElement>> ReturnWaitingFunction(IElementLocator locator, IEnumerable<By> bys) { return (IElementLocator) => { List<IWebElement> result = new List<IWebElement>(); foreach (var by in bys) { try { List<By> listOfSingleBy = new List<By>(); listOfSingleBy.Add(by); result.AddRange(locator.LocateElements(listOfSingleBy)); } catch (NoSuchElementException e) { continue; } catch (Exception e) { if (!IsInvalidSelectorRootCause(e)) throw e; continue; } } if (result.Count > 0) return result.AsReadOnly(); return null; }; }
/// <summary> /// Creates an object used to proxy calls to properties and methods of an <see cref="IWebElement"/> object. /// </summary> /// <param name="classToProxy">The <see cref="Type"/> of object for which to create a proxy.</param> /// <param name="locator">The <see cref="IElementLocator"/> implementation that /// determines how elements are located.</param> /// <param name="bys">The list of methods by which to search for the elements.</param> /// <param name="cacheLookups"><see langword="true"/> to cache the lookup to the element; otherwise, <see langword="false"/>.</param> /// <returns>An object used to proxy calls to properties and methods of the list of <see cref="IWebElement"/> objects.</returns> public static T CreateProxy(Type classToProxy, IElementLocator locator, IEnumerable <By> bys) { object proxy = Create <T, WebElementProxy <T> >(); ((WebElementProxy <T>)proxy).SetParamateres(classToProxy, locator, bys); return((T)proxy); }
public MenuControl(IElement parent, IElementLocator locator) : base(parent, locator) { //this.TxtUserName = WebElement.Create(this, ElementLocator.Create(By.Id, "userName")); //this.TxtPassword = WebElement.Create(this, ElementLocator.Create(By.Id, "password")); //this.BtnLogin = WebElement.CreateNavigation<Test000HomePage>(this, ElementLocator.Create(By.Id, "login")); }
public WebElementInterceptor(IElementLocator locator, IEnumerable <By> bys, IReporter reporter, string name) { this.locator = locator; this.bys = bys; this.reporter = reporter; elementName = name; }
/// <summary> /// Locates an element or list of elements for a Page Object member, and returns a /// proxy object for the element or list of elements. /// </summary> /// <param name="member">The <see cref="MemberInfo"/> containing information about /// a class's member.</param> /// <param name="locator">The <see cref="IElementLocator"/> used to locate elements.</param> /// <returns>A transparent proxy to the WebDriver element object.</returns> public object Decorate(MemberInfo member, IElementLocator locator) { FieldInfo field = member as FieldInfo; PropertyInfo property = member as PropertyInfo; Type targetType = null; if (field != null) { targetType = field.FieldType; } bool hasPropertySet = false; if (property != null) { hasPropertySet = property.CanWrite; targetType = property.PropertyType; } if (field == null & (property == null || !hasPropertySet)) { return(null); } IList <By> bys = CreateLocatorList(member); if (bys.Count > 0) { return(CreateProxyObject(targetType, member.Name, locator, bys, containerId, reporter)); } return(null); }
/// <summary> /// Locates an element or list of elements for a Page Object member, and returns a /// proxy object for the element or list of elements. /// </summary> /// <param name="member">The <see cref="MemberInfo"/> containing information about /// a class's member.</param> /// <param name="locator">The <see cref="IElementLocator"/> used to locate elements.</param> /// <returns>A transparent proxy to the WebDriver element object.</returns> public object Decorate(MemberInfo member, IElementLocator locator) { object proxyObject = DecorateObject(member, locator); _membersDictionary.Add(member, proxyObject); return(proxyObject); }
/// <summary> /// Locates an element or list of elements for a Page Object member, and returns a /// proxy object for the element or list of elements. /// </summary> /// <param name="member">The <see cref="MemberInfo"/> containing information about /// a class's member.</param> /// <param name="locator">The <see cref="IElementLocator"/> used to locate elements.</param> /// <returns>A transparent proxy to the WebDriver element object.</returns> public object Decorate(MemberInfo member, IElementLocator locator) { FieldInfo field = member as FieldInfo; PropertyInfo property = member as PropertyInfo; Type targetType = null; if (field != null) { targetType = field.FieldType; } bool hasPropertySet = false; if (property != null) { hasPropertySet = property.CanWrite; targetType = property.PropertyType; } if (field == null & (property == null || !hasPropertySet)) { return null; } IList<By> bys = CreateLocatorList(member); if (bys.Count > 0) { bool cache = ShouldCacheLookup(member); object proxyObject = CreateProxyObject(targetType, locator, bys, cache); return proxyObject; } return null; }
public static OpenQA.Selenium.By?ToSeleniumLocator(this IElementLocator seleniumLocator) { switch (seleniumLocator.LocatorType) { case SpecDrill.SecondaryPorts.AutomationFramework.By.ClassName: return(OpenQA.Selenium.By.ClassName(seleniumLocator.LocatorValue)); case SpecDrill.SecondaryPorts.AutomationFramework.By.CssSelector: return(OpenQA.Selenium.By.CssSelector(seleniumLocator.LocatorValue)); case SpecDrill.SecondaryPorts.AutomationFramework.By.Id: return(OpenQA.Selenium.By.Id(seleniumLocator.LocatorValue)); case SpecDrill.SecondaryPorts.AutomationFramework.By.LinkText: return(OpenQA.Selenium.By.LinkText(seleniumLocator.LocatorValue)); case SpecDrill.SecondaryPorts.AutomationFramework.By.Name: return(OpenQA.Selenium.By.Name(seleniumLocator.LocatorValue)); case SpecDrill.SecondaryPorts.AutomationFramework.By.PartialLinkText: return(OpenQA.Selenium.By.PartialLinkText(seleniumLocator.LocatorValue)); case SpecDrill.SecondaryPorts.AutomationFramework.By.TagName: return(OpenQA.Selenium.By.TagName(seleniumLocator.LocatorValue)); case SpecDrill.SecondaryPorts.AutomationFramework.By.XPath: return(OpenQA.Selenium.By.XPath(seleniumLocator.LocatorValue)); } return(null); }
public MenuControl(Browser browser, IElement parent, IElementLocator locator) : base(browser, parent, locator) { this.TxtUserName = WebElement.Create(this.browser, this, ElementLocator.Create(By.Id, "userName")); this.TxtPassword = WebElement.Create(this.browser, this, ElementLocator.Create(By.Id, "password")); this.BtnLogin = WebElement.CreateNavigation <Test000HomePage>(this.browser, this, ElementLocator.Create(By.Id, "login")); }
/// <summary> /// Initializes the elements in the Page Object. /// </summary> /// <param name="page">The Page Object to be populated with elements.</param> /// <param name="locator">The <see cref="IElementLocator"/> implementation that /// determines how elements are located.</param> /// <param name="decorator">The <see cref="IPageObjectMemberDecorator"/> implementation that /// determines how Page Object members representing elements are discovered and populated.</param> /// <exception cref="ArgumentException"> /// thrown if a field or property decorated with the <see cref="FindsByAttribute"/> is not of type /// <see cref="IWebElement"/> or IList{IWebElement}. /// </exception> public static void InitElements(object page, IElementLocator locator, IPageObjectMemberDecorator decorator) { if (page == null) { throw new ArgumentNullException(nameof(page), "page cannot be null"); } if (locator == null) { throw new ArgumentNullException(nameof(locator), "locator cannot be null"); } if (decorator == null) { throw new ArgumentNullException(nameof(locator), "decorator cannot be null"); } if (locator.SearchContext == null) { throw new ArgumentException("The SearchContext of the locator object cannot be null", nameof(locator)); } const BindingFlags PublicBindingOptions = BindingFlags.Instance | BindingFlags.Public; const BindingFlags NonPublicBindingOptions = BindingFlags.Instance | BindingFlags.NonPublic; // Get a list of all of the fields and properties (public and non-public [private, protected, etc.]) // in the passed-in page object. Note that we walk the inheritance tree to get superclass members. Type?type = page.GetType(); var members = new List <MemberInfo>(); members.AddRange(type.GetFields(PublicBindingOptions)); members.AddRange(type.GetProperties(PublicBindingOptions)); while (type != null) { members.AddRange(type.GetFields(NonPublicBindingOptions)); members.AddRange(type.GetProperties(NonPublicBindingOptions)); type = type.BaseType; } foreach (var member in members) { // Examine each member, and if the decorator returns a non-null object, // set the value of that member to the decorated object. object?decoratedValue = decorator.Decorate(member, locator); if (decoratedValue == null) { continue; } if (member is FieldInfo field) { field.SetValue(page, decoratedValue); } else if (member is PropertyInfo property && property.CanWrite) { property.SetValue(page, decoratedValue, null); } } }
public ReadOnlyCollection <object> FindElements(IElementLocator locator) { var result = new List <object>(); var elements = seleniumDriver.FindElements(locator.ToSelenium()); result.AddRange(elements); return(new ReadOnlyCollection <object>(result)); }
public ElementLoader(IElementLocator locator, Boolean cache) : base(locator.FindElement, IsElementLoaded) { UseCash = cache; IgnoredExceptionTypes = new List <Type> { typeof(StaleElementReferenceException) }; }
public void Ctor_ArgumentNullExceptions(IElementLocator elementLocator, IPageObjectMemberDecorator pageObjectMemberDecorator) { new Action(() => new PageObjectFactory(elementLocator, null)).Should() .Throw <ArgumentNullException>(); new Action(() => new PageObjectFactory(null, pageObjectMemberDecorator)).Should() .Throw <ArgumentNullException>(); }
public static IWebElement Create(IElementLocator elementLocator, IEnumerable <By> bys) { var proxiedObject = DispatchProxy.Create <IWebElement, WebElementProxy>(); (proxiedObject as WebElementProxy)?.SetParameters(elementLocator, bys); return(proxiedObject); }
public object Decorate(MemberInfo member, IElementLocator locator) { FieldInfo field = member as FieldInfo; PropertyInfo property = member as PropertyInfo; Type targetType = null; targetType = field?.FieldType; bool hasPropertySet = false; if (property != null) { hasPropertySet = property.CanWrite; targetType = property?.PropertyType; } if (field == null & (property == null || !hasPropertySet)) { return(null); } if (field != null && (field.IsStatic || field.IsInitOnly)) { return(null); } Type aSingleElementType = GetTypeOfASingleElement(targetType, member); Type aListOfElementsType = null; if (GenericsUtility.MatchGenerics(typeof(IList <>), ListOfAvailableElementTypes, targetType)) { aListOfElementsType = targetType; } if (aSingleElementType == null & aListOfElementsType == null) { return(null); } ISearchContext context = locator.SearchContext; IEnumerable <By> bys = ByFactory.CreateBys(context, member); ProxyGenerator generator = new ProxyGenerator(); TimeOutDuration span = GetTimeWaitingForElements(member); bool shouldCache = (Attribute.GetCustomAttribute(member, typeof(CacheLookupAttribute), true) != null); if (aSingleElementType != null) { return(generator.CreateInterfaceProxyWithoutTarget(aSingleElementType, new Type[] { typeof(IWrapsDriver), typeof(IWrapsElement) }, ProxyGenerationOptions.Default, new ElementInterceptor(bys, locator, span, shouldCache))); } return(generator.CreateInterfaceProxyWithoutTarget(aListOfElementsType, ProxyGenerationOptions.Default, new ElementListInterceptor(bys, locator, span, shouldCache))); }
public SearchingInterceptor(IEnumerable<By> bys, IElementLocator locator, TimeOutDuration waitingTimeSpan, bool shouldCache) { this.locator = locator; this.waitingTimeSpan = waitingTimeSpan; this.shouldCache = shouldCache; this.bys = bys; waitingForElementList = new DefaultWait<IElementLocator>(locator); waitingForElementList.IgnoreExceptionTypes(new Type[] { typeof(StaleElementReferenceException)}); }
/// <summary> /// Decorates the typified element. /// </summary> /// <param name="elementType">Type of the element.</param> /// <param name="locator">The locator.</param> /// <param name="elementName">Name of the element.</param> /// <returns>The value.</returns> private TypifiedElement DecorateTypifiedElement(Type elementType, IElementLocator locator, string elementName) { // Create typified element and initialize it with WebElement proxy var elementToWrap = HtmlElementFactory.CreateNamedProxyForWebElement(locator, elementName); var typifiedElementInstance = HtmlElementFactory.CreateTypifiedElementInstance(elementType, elementToWrap); typifiedElementInstance.Name = elementName; return(typifiedElementInstance); }
private HtmlElement DecorateHtmlElement(Type elementType, IElementLocator locator, string elementName) { // Create block and initialize it with WebElement proxy IWebElement elementToWrap = HtmlElementFactory.CreateNamedProxyForWebElement(locator, elementName); HtmlElement htmlElementInstance = HtmlElementFactory.CreateHtmlElementInstance(elementType); htmlElementInstance.WrappedElement = elementToWrap; htmlElementInstance.Name = elementName; // Recursively initialize elements of the block PageFactory.InitElements(new HtmlElementDecorator(elementToWrap), htmlElementInstance); return htmlElementInstance; }
public object Decorate(MemberInfo member, IElementLocator locator) { FieldInfo field = member as FieldInfo; PropertyInfo property = member as PropertyInfo; Type targetType = null; if (field != null) { targetType = field.FieldType; } bool hasPropertySet = false; if (property != null) { hasPropertySet = property.CanWrite; targetType = property.PropertyType; } if (field == null & (property == null || !hasPropertySet)) return null; if (field != null && (field.IsStatic || field.IsInitOnly)) return null; Type aSingleElementType = GetTypeOfASingleElement(targetType, member); Type aListOfElementsType = null; if (GenericsUtility.MatchGenerics(typeof(IList<>), ListOfAvailableElementTypes, targetType)) aListOfElementsType = targetType; if (aSingleElementType == null & aListOfElementsType == null) return null; ISearchContext context = locator.SearchContext; IEnumerable<By> bys = ByFactory.CreateBys(context, member); ProxyGenerator generator = new ProxyGenerator(); TimeOutDuration span = GetTimeWaitingForElements(member); bool shouldCache = (Attribute. GetCustomAttribute(member, typeof(CacheLookupAttribute), true) != null); if (aSingleElementType != null) return generator.CreateInterfaceProxyWithoutTarget(aSingleElementType, new Type[] { typeof(IWrapsDriver), typeof(IWrapsElement) }, ProxyGenerationOptions.Default, new ElementInterceptor(bys, locator, span, shouldCache)); return generator.CreateInterfaceProxyWithoutTarget(aListOfElementsType, ProxyGenerationOptions.Default, new ElementListInterceptor(bys, locator, span, shouldCache)); }
internal static object CreateNamedProxyForWebElementList(IElementLocator locator, string listName) { return WebElementListNamedProxyHandler.newInstance(locator, listName); }
public SearchResultItemControl(IElement parent, IElementLocator locator) : base(parent, locator) { }
public ElementInterceptor(IEnumerable<By> bys, IElementLocator locator, TimeOutDuration waitingTimeSpan, bool shouldCache) : base(bys, locator, waitingTimeSpan, shouldCache) { driver = WebDriverUnpackUtility.UnpackWebdriver(locator.SearchContext); }
private IWebElement DecorateWebElement(IElementLocator locator, string elementName) { return HtmlElementFactory.CreateNamedProxyForWebElement(locator, elementName); }
public static IWebElement CreateNamedProxyForWebElement(IElementLocator locator, string elementName) { return WebElementNamedProxyHandler.newInstance(locator, elementName); }
/// <summary> /// Initializes a new instance of the <see cref="WebElementProxy"/> class. /// </summary> /// <param name="classToProxy">The <see cref="Type"/> of object for which to create a proxy.</param> /// <param name="locator">The <see cref="IElementLocatorFactory"/> implementation that /// determines how elements are located.</param> /// <param name="bys">The list of methods by which to search for the elements.</param> /// <param name="cache"><see langword="true"/> to cache the lookup to the element; otherwise, <see langword="false"/>.</param> private WebElementProxy(Type classToProxy, IElementLocator locator, IEnumerable<By> bys, bool cache) : base(classToProxy, locator, bys, cache) { }
private object DecorateHtmlElementList(Type listType, Type elementType, IElementLocator locator, string listName) { return HtmlElementFactory.CreateNamedProxyForHtmlElementList(listType, elementType, locator, listName); }
public static IList<IWebElement> newInstance(IElementLocator locator, string name) { return new WebElementListNamedProxyHandler(locator, name).ActLike<IList<IWebElement>>(); }
private object ProxyForLocator(IElementLocator locator) { return WebElementProxyHandler.newInstance(locator); }
private TypifiedElement DecorateTypifiedElement(Type elementType, IElementLocator locator, string elementName) { // Create typified element and initialize it with WebElement proxy IWebElement elementToWrap = HtmlElementFactory.CreateNamedProxyForWebElement(locator, elementName); TypifiedElement typifiedElementInstance = HtmlElementFactory.CreateTypifiedElementInstance(elementType, elementToWrap); typifiedElementInstance.Name = elementName; return typifiedElementInstance; }
public MenuListItemControl(IElement parent, IElementLocator locator) : base(parent, locator) { //LnkLogin = WebElement.CreateNavigation<Test000LoginPage>(parent, ElementLocator.Create(By.PartialLinkText, "Login")); //LnkHome = WebElement.CreateNavigation<Test000HomePage>(parent, ElementLocator.Create(By.PartialLinkText, "Home")); }
/// <summary> /// Creates an object used to proxy calls to properties and methods of the /// list of <see cref="IWebElement"/> objects. /// </summary> /// <param name="classToProxy">The <see cref="Type"/> of object for which to create a proxy.</param> /// <param name="locator">The <see cref="IElementLocator"/> implementation that /// determines how elements are located.</param> /// <param name="bys">The list of methods by which to search for the elements.</param> /// <param name="cacheLookups"><see langword="true"/> to cache the lookup to the /// element; otherwise, <see langword="false"/>.</param> /// <returns>An object used to proxy calls to properties and methods of the /// list of <see cref="IWebElement"/> objects.</returns> public static object CreateProxy(Type classToProxy, IElementLocator locator, IEnumerable<By> bys, bool cacheLookups) { return new WebElementListProxy(classToProxy, locator, bys, cacheLookups).GetTransparentProxy(); }
/// <summary> /// Initializes a new instance of the <see cref="WebElementListProxy"/> class. /// </summary> /// <param name="typeToBeProxied">The <see cref="Type"/> of object for which to create a proxy.</param> /// <param name="locator">The <see cref="IElementLocator"/> implementation that /// determines how elements are located.</param> /// <param name="bys">The list of methods by which to search for the elements.</param> /// <param name="cache"><see langword="true"/> to cache the lookup to the element; otherwise, <see langword="false"/>.</param> private WebElementListProxy(Type typeToBeProxied, IElementLocator locator, IEnumerable<By> bys, bool cache) : base(typeToBeProxied, locator, bys, cache) { }
public PassedTestHandler(IElementLocator elementLocator, IWebElement testElement,int testIndex) : base(elementLocator, testElement,testIndex) { }
private object DecorateWebElementList(IElementLocator locator, string listName) { return HtmlElementFactory.CreateNamedProxyForWebElementList(locator, listName); }
private WebElementListNamedProxyHandler(IElementLocator locator, string name) : base() { this.locator = locator; this.name = name; }
private WebElementProxyHandler(IElementLocator locator) : base() { this.locator = locator; }
internal static object CreateNamedProxyForTypifiedElementList(Type listType, Type elementType, IElementLocator locator, string listName) { return TypifiedElementListNamedProxyHandler.newInstance(listType, elementType, locator, listName); }
public static IWebElement newInstance(IElementLocator locator) { return new WebElementProxyHandler(locator).ActLike<IWebElement>(); }
public static IList<HtmlElement> newInstance(Type listType, Type elementType, IElementLocator locator, string name) { return new HtmlElementListNamedProxyHandler(elementType, locator, name).ActLike(listType); }
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; }