class DefaultPropertyDecorator implements IPropertyDecorator (View source)

Default decorator for use with PageFactory. Will decorate 1) all of the WebElement fields and 2) List fields that have @FindBy or \@FindBys annotation with a proxy that locates the elements using the passed in ElementLocatorFactory.

Properties

protected IElementLocatorFactory $locatorFactory Locator factory.
protected IPageFactory $pageFactory Page factory.
protected array $elementToProxyMapping Mapping between element classes, that factory supports and how to proxy them.

Methods

__construct(IElementLocatorFactory $locator_factory, IPageFactory $page_factory)

Creates decorator instance.

decorate(Property $property)

This method is called by PageFactory on all properties to decide how to decorate the property.

boolean
canDecorate(Property $property)

Checks if a property can be decorated.

IProxy|null
doDecorate(Property $property, IElementLocator $locator)

Perform actual decoration.

string
getProxyClass(Property $property)

Returns proxy class, that can be used alongside with element class of a property.

boolean
classMatches(string $class_name, string $descendant_of)

Ensures that 2 given classes has a relation.

Expectation
shouldReceive(string $name)

No description

Details

__construct(IElementLocatorFactory $locator_factory, IPageFactory $page_factory)

Creates decorator instance.

Parameters

IElementLocatorFactory $locator_factory Locator factory.
IPageFactory $page_factory Page factory.

IProxy decorate(Property $property)

This method is called by PageFactory on all properties to decide how to decorate the property.

Parameters

Property $property The property that may be decorated.

Return Value

IProxy

protected boolean canDecorate(Property $property)

Checks if a property can be decorated.

Parameters

Property $property The property that may be decorated.

Return Value

boolean

Exceptions

PageFactoryException When class of non-existing element discovered in property's @var annotation.

protected IProxy|null doDecorate(Property $property, IElementLocator $locator)

Perform actual decoration.

Parameters

Property $property The property that may be decorated.
IElementLocator $locator Locator.

Return Value

IProxy|null

protected string getProxyClass(Property $property)

Returns proxy class, that can be used alongside with element class of a property.

Parameters

Property $property Property.

Return Value

string

protected boolean classMatches(string $class_name, string $descendant_of)

Ensures that 2 given classes has a relation.

Parameters

string $class_name Class name to test.
string $descendant_of Required descendant class.

Return Value

boolean

Expectation shouldReceive(string $name)

Parameters

string $name

Return Value

Expectation