HtmlElement.Net
Public Member Functions | Protected Member Functions | List of all members
HtmlElements.AbstractPageObjectFactory Class Referenceabstract

Implements IPageObjectFactory contract and delegates responsibility for creating actual page object and initializing it's members to subclasses. It class takes care of locating suitable for initialization members and assigning value to it. It looks for all instance fields and properties which are web elements or web element lists and have not been assigned value yet. Both fields and properties can be private protected or public, but in order to be initialized fields should not be marked readonlyand properties should have setters. More...

Inherits HtmlElements.IPageObjectFactory.

Inherited by HtmlElements.PageObjectFactory.

Public Member Functions

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...
 
abstract IWebElement CreateWebElement (ISearchContext searchContext, By locator)
 Creates WebElement found with provided locator in given search context More...
 
abstract ReadOnlyCollection< IWebElement > CreateWebElementList (ISearchContext searchContext, By locator)
 Creates list of WebElements found with provided locator in given search context More...
 
abstract TPageObject CreateWebElement< TPageObject > (ISearchContext searchContext, By locator)
 Creates and initializes page object of a given type and all nested page objects. More...
 
abstract IList< TPageObject > CreateWebElementList< TPageObject > (ISearchContext searchContext, By locator)
 Creates and initializes list of page elements and it's nested page objects. More...
 

Protected Member Functions

abstract object CreateMemberInstance (Type memberType, MemberInfo memberInfo, ISearchContext searchContext)
 Creates value assigned to page object member (field or property). More...
 
abstract object CreatePageObjectInstance (Type pageObjectType, ISearchContext searchContext)
 Create instance of page object class. It is not responsible for initializing page object members. More...
 

Detailed Description

Implements IPageObjectFactory contract and delegates responsibility for creating actual page object and initializing it's members to subclasses. It class takes care of locating suitable for initialization members and assigning value to it. It looks for all instance fields and properties which are web elements or web element lists and have not been assigned value yet. Both fields and properties can be private protected or public, but in order to be initialized fields should not be marked

readonly

and properties should have setters.

Member Function Documentation

◆ Create()

object HtmlElements.AbstractPageObjectFactory.Create ( Type  pageObjectType,
ISearchContext  searchContext 
)

Creates and initializes page object of a given type and all nested page objects.

Parameters
pageObjectTypePage object type
searchContextContext used for finding elements
Returns
Fully initialized page object

Implements HtmlElements.IPageObjectFactory.

◆ Create< TPageObject >()

TPageObject HtmlElements.AbstractPageObjectFactory.Create< TPageObject > ( ISearchContext  searchContext)

Creates and initializes page object of a given type and all nested page objects.

Template Parameters
TPageObjectPage object type
Parameters
searchContextContext used for finding elements
Returns
Fully initialized page object

Implements HtmlElements.IPageObjectFactory.

◆ CreateMemberInstance()

abstract object HtmlElements.AbstractPageObjectFactory.CreateMemberInstance ( Type  memberType,
MemberInfo  memberInfo,
ISearchContext  searchContext 
)
protectedpure virtual

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

Implemented in HtmlElements.PageObjectFactory.

◆ CreatePageObjectInstance()

abstract object HtmlElements.AbstractPageObjectFactory.CreatePageObjectInstance ( Type  pageObjectType,
ISearchContext  searchContext 
)
protectedpure virtual

Create instance of page object class. It is not responsible for initializing page object members.

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

Implemented in HtmlElements.PageObjectFactory.

◆ CreateWebElement()

abstract IWebElement HtmlElements.AbstractPageObjectFactory.CreateWebElement ( ISearchContext  searchContext,
By  locator 
)
pure virtual

Creates WebElement found with provided locator in given search context

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

Implements HtmlElements.IPageObjectFactory.

Implemented in HtmlElements.PageObjectFactory.

◆ CreateWebElement< TPageObject >()

abstract TPageObject HtmlElements.AbstractPageObjectFactory.CreateWebElement< TPageObject > ( ISearchContext  searchContext,
By  locator 
)
pure virtual

Creates and initializes page object of a given type and all nested page objects.

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.IPageObjectFactory.

Implemented in HtmlElements.PageObjectFactory.

Type Constraints
TPageObject :class 

◆ CreateWebElementList()

abstract ReadOnlyCollection<IWebElement> HtmlElements.AbstractPageObjectFactory.CreateWebElementList ( ISearchContext  searchContext,
By  locator 
)
pure virtual

Creates 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
Custom list of WebElements

Implements HtmlElements.IPageObjectFactory.

Implemented in HtmlElements.PageObjectFactory.

◆ CreateWebElementList< TPageObject >()

abstract IList<TPageObject> HtmlElements.AbstractPageObjectFactory.CreateWebElementList< TPageObject > ( ISearchContext  searchContext,
By  locator 
)
pure 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.IPageObjectFactory.

Implemented in HtmlElements.PageObjectFactory.

◆ Init() [1/2]

void HtmlElements.AbstractPageObjectFactory.Init ( object  pageObject,
ISearchContext  searchContext 
)

Initialize web elements in given page object instance

Parameters
pageObjectNot initialized page object
searchContextContext used for finding elements

Implements HtmlElements.IPageObjectFactory.

◆ Init() [2/2]

void HtmlElements.AbstractPageObjectFactory.Init ( WebDriverWrapper  pageObject)

Initialize page object using it's wrapped context

Parameters
pageObjectPage object instance to be initialized

Implements HtmlElements.IPageObjectFactory.