HtmlElement.Net
Public Member Functions | Protected Member Functions | List of all members
HtmlElements.PageObjectFactory Class Reference

Default page object implementation creating lazy loading proxies for every web element or list of web elements. It can't handle multiple FindsByAttribute attributes as well as FindsBySequenceAttribute and FindsByAllAttribute. More...

Inherits HtmlElements.AbstractPageObjectFactory.

Public Member Functions

 PageObjectFactory ()
 Creates page factory instance using ProxyFactory for creating lazy loading error handling proxies and LoaderFactory for creating lazy loaded elements and element lists. More...
 
 PageObjectFactory (IProxyFactory proxyFactory, ILoaderFactory loaderFactory)
 Creates page factory instance using provided proxyFactory for creating proxies and loaderFactory for creating lazy elements and list of elements. More...
 
override IWebElement CreateWebElement (ISearchContext searchContext, By locator)
 Creates lazy loaded WebElement found with provided locator in given search context. More...
 
override TPageObject CreateWebElement< TPageObject > (ISearchContext searchContext, By locator)
 Creates and initializes page object of a given type and all nested page objects using WebElement found within given context by provided locator. More...
 
override ReadOnlyCollection< IWebElement > CreateWebElementList (ISearchContext searchContext, By locator)
 Creates lazy loaded list of WebElements found with provided locator in given search context More...
 
override IList< TPageObject > CreateWebElementList< TPageObject > (ISearchContext searchContext, By locator)
 Creates and initializes list of page elements and it's nested page objects. More...
 
- Public Member Functions inherited from HtmlElements.AbstractPageObjectFactory
object Create (Type pageObjectType, ISearchContext searchContext)
 Creates and initializes page object of a given type and all nested page objects. More...
 
TPageObject Create< TPageObject > (ISearchContext searchContext)
 Creates and initializes page object of a given type and all nested page objects. More...
 
void Init (object pageObject, ISearchContext searchContext)
 Initialize web elements in given page object instance More...
 
void Init (WebDriverWrapper pageObject)
 Initialize page object using it's wrapped context More...
 

Protected Member Functions

override object CreateMemberInstance (Type memberType, MemberInfo memberInfo, ISearchContext searchContext)
 Creates value assigned to page object member (field or property). More...
 
override object CreatePageObjectInstance (Type pageObjectType, ISearchContext searchContext)
 Creates page object using two-arguments constructor ( ISearchContext and IPageObjectFactory) or single argument constructor ( ISearchContext) or default constructor. More...
 

Detailed Description

Default page object implementation creating lazy loading proxies for every web element or list of web elements. It can't handle multiple FindsByAttribute attributes as well as FindsBySequenceAttribute and FindsByAllAttribute.

It supports CacheLookupAttribute for elements and element lists by using same raw web element once it have been found. It also supports smart frames (derived from HtmlFrame class) which can host nested elements and automatically switch context.

Factory requires nested page objects to have default constructor or constructor accepting IWebElement as a single argument or IWebElement as first argument and IPageObjectFactory as second.

When IPageObjectFactory.Create<TPageObject> is called directly it will pass instance of search context being provided as first constructor argument and itself as second (if needed). It also can use default constructor.

Constructor & Destructor Documentation

◆ PageObjectFactory() [1/2]

HtmlElements.PageObjectFactory.PageObjectFactory ( )

Creates page factory instance using ProxyFactory for creating lazy loading error handling proxies and LoaderFactory for creating lazy loaded elements and element lists.

◆ PageObjectFactory() [2/2]

HtmlElements.PageObjectFactory.PageObjectFactory ( IProxyFactory  proxyFactory,
ILoaderFactory  loaderFactory 
)

Creates page factory instance using provided proxyFactory for creating proxies and loaderFactory for creating lazy elements and list of elements.

Parameters
proxyFactoryFactory creating WebElement and WebElement list proxies.
loaderFactoryFactory creating WebElement and WebElement list loaders.

Member Function Documentation

◆ CreateMemberInstance()

override object HtmlElements.PageObjectFactory.CreateMemberInstance ( Type  memberType,
MemberInfo  memberInfo,
ISearchContext  searchContext 
)
protectedvirtual

Creates value assigned to page object member (field or property).

Parameters
memberTypeDeclared type of property or field.
memberInfoField or property meta information.
searchContextParent page object context.
Returns
Initialized field or property value or null.

Implements HtmlElements.AbstractPageObjectFactory.

◆ CreatePageObjectInstance()

override object HtmlElements.PageObjectFactory.CreatePageObjectInstance ( Type  pageObjectType,
ISearchContext  searchContext 
)
protectedvirtual

Creates page object using two-arguments constructor ( ISearchContext and IPageObjectFactory) or single argument constructor ( ISearchContext) or default constructor.

Parameters
pageObjectTypeType of page object being initialized.
searchContextOptional constructor argument representing search context being wrapped. It could be IWebElement or IWebDriver instance or other page object.
Returns
New instance of given type.

Implements HtmlElements.AbstractPageObjectFactory.

◆ CreateWebElement()

override IWebElement HtmlElements.PageObjectFactory.CreateWebElement ( ISearchContext  searchContext,
By  locator 
)
virtual

Creates lazy loaded WebElement found with provided locator in given search context.

Parameters
searchContextContext used for finding element.
locatorElement locator to use for finding element.
Returns
Lazy loaded WebElement found in given search context with provided locator.

Implements HtmlElements.AbstractPageObjectFactory.

◆ CreateWebElement< TPageObject >()

override TPageObject HtmlElements.PageObjectFactory.CreateWebElement< TPageObject > ( ISearchContext  searchContext,
By  locator 
)
virtual

Creates and initializes page object of a given type and all nested page objects using WebElement found within given context by provided locator.

Template Parameters
TPageObjectPage object class.
Parameters
searchContextParent context used for finding the element used as page element root.
locatorLocator used for finding underlying WebElement used as page element root.
Returns
Fully initialized page object using WebElement found in searchContext with locator for finding nested elements.

Implements HtmlElements.AbstractPageObjectFactory.

◆ CreateWebElementList()

override ReadOnlyCollection<IWebElement> HtmlElements.PageObjectFactory.CreateWebElementList ( ISearchContext  searchContext,
By  locator 
)
virtual

Creates lazy loaded list of WebElements found with provided locator in given search context

Parameters
searchContextContext used for finding elements
locatorElement locator to use for finding elements
Returns
Lazy loaded list of WebElements

Implements HtmlElements.AbstractPageObjectFactory.

◆ CreateWebElementList< TPageObject >()

override IList<TPageObject> HtmlElements.PageObjectFactory.CreateWebElementList< TPageObject > ( ISearchContext  searchContext,
By  locator 
)
virtual

Creates and initializes list of page elements and it's nested page objects.

Template Parameters
TPageObjectThe type of the page object.
Parameters
searchContextThe search context used for finding underlying WebElements.
locatorThe locator used for finding underlying WebElements.
Returns
List of initialized page objects wrapping elements found in searchContext with locator .

Implements HtmlElements.AbstractPageObjectFactory.