class Block extends AbstractPart implements IBlock (View source)

All BEM block classes must be descendants of this class.

Properties

private string $_name Name of the BEM part. from AbstractPart
private NodeElement[] $_nodes Elements, associated with this block.
private BEMElementLocator $_locator Locator.

Methods

__construct(string $name, array $nodes, IPageFactory $page_factory, BEMElementLocator $locator)

Create instance of BEM block.

string
getName()

Returns element name.

Expectation
shouldReceive(string $name)

No description

NodeElement[]
getNodes()

Returns block nodes.

NodeElement[]|null
getElement(string $element_name, string $modificator_name = null, string $modificator_value = null)

Returns first block element.

NodeElement[]
getElements(string $element_name, string $modificator_name = null, string $modificator_value = null)

Returns all block elements.

NodeElement|null
find(string $selector, string|array $locator)

Finds first element with specified selector.

NodeElement[]
findAll(string $selector, string|array $locator)

Finds all elements with specified selector.

mixed
waitFor(integer $timeout, callable $callback)

Waits for an element(-s) to appear and returns it.

Details

final __construct(string $name, array $nodes, IPageFactory $page_factory, BEMElementLocator $locator)

Create instance of BEM block.

Parameters

string $name BEM part name.
array $nodes Nodes associated with this block.
IPageFactory $page_factory Page factory.
BEMElementLocator $locator Locator.

string getName()

Returns element name.

Return Value

string

Expectation shouldReceive(string $name)

Parameters

string $name

Return Value

Expectation

NodeElement[] getNodes()

Returns block nodes.

Return Value

NodeElement[]

NodeElement[]|null getElement(string $element_name, string $modificator_name = null, string $modificator_value = null)

Returns first block element.

Parameters

string $element_name Element name.
string $modificator_name Modificator name.
string $modificator_value Modificator value.

Return Value

NodeElement[]|null

NodeElement[] getElements(string $element_name, string $modificator_name = null, string $modificator_value = null)

Returns all block elements.

Parameters

string $element_name Element name.
string $modificator_name Modificator name.
string $modificator_value Modificator value.

Return Value

NodeElement[]

NodeElement|null find(string $selector, string|array $locator)

Finds first element with specified selector.

Parameters

string $selector Selector engine name.
string|array $locator Selector locator.

Return Value

NodeElement|null

NodeElement[] findAll(string $selector, string|array $locator)

Finds all elements with specified selector.

Parameters

string $selector Selector engine name.
string|array $locator Selector locator.

Return Value

NodeElement[]

mixed waitFor(integer $timeout, callable $callback)

Waits for an element(-s) to appear and returns it.

Parameters

integer $timeout Maximal allowed waiting time in seconds.
callable $callback Callback, which result is both used as waiting condition and returned. Will receive reference to this element as first argument.

Return Value

mixed

Exceptions

LogicException Always.