HasElement

class HasElement extends PageConstraint (View source)

Properties

protected string $selector The name or ID of the element.
protected array $attributes The attributes the element should have.

Methods

string html(Crawler|string $crawler)

Make sure we obtain the HTML from the crawler or the response.

from PageConstraint
string text(Crawler|string $crawler)

Make sure we obtain the HTML from the crawler or the response.

from PageConstraint
Crawler crawler(Crawler|string $crawler)

Create a crawler instance if the given value is not already a Crawler.

from PageConstraint
string getEscapedPattern(string $text)

Get the escaped text pattern for the constraint.

from PageConstraint
void fail(Crawler|string $crawler, string $description, ComparisonFailure $comparisonFailure = null)

Throw an exception for the given comparison and test description.

from PageConstraint
string getFailureDescription()

Get the description of the failure.

from PageConstraint
string getReverseFailureDescription()

Returns the reversed description of the failure.

from PageConstraint
string toString()

Returns a string representation of the object.

void __construct(string $selector, array $attributes = [])

Create a new constraint instance.

bool matches(Crawler|string $crawler)

Check if the element is found in the given crawler.

bool hasAttributes(Crawler $element)

Determines if the given element has the attributes.

Details

protected string html(Crawler|string $crawler)

Make sure we obtain the HTML from the crawler or the response.

Parameters

Crawler|string $crawler

Return Value

string

protected string text(Crawler|string $crawler)

Make sure we obtain the HTML from the crawler or the response.

Parameters

Crawler|string $crawler

Return Value

string

protected Crawler crawler(Crawler|string $crawler)

Create a crawler instance if the given value is not already a Crawler.

Parameters

Crawler|string $crawler

Return Value

Crawler

protected string getEscapedPattern(string $text)

Get the escaped text pattern for the constraint.

Parameters

string $text

Return Value

string

protected void fail(Crawler|string $crawler, string $description, ComparisonFailure $comparisonFailure = null)

Throw an exception for the given comparison and test description.

Parameters

Crawler|string $crawler
string $description
ComparisonFailure $comparisonFailure

Return Value

void

Exceptions

PHPUnit_Framework_ExpectationFailedException

protected string getFailureDescription()

Get the description of the failure.

Return Value

string

protected string getReverseFailureDescription()

Returns the reversed description of the failure.

Return Value

string

string toString()

Returns a string representation of the object.

Return Value

string

void __construct(string $selector, array $attributes = [])

Create a new constraint instance.

Parameters

string $selector
array $attributes

Return Value

void

bool matches(Crawler|string $crawler)

Check if the element is found in the given crawler.

Parameters

Crawler|string $crawler

Return Value

bool

protected bool hasAttributes(Crawler $element)

Determines if the given element has the attributes.

Parameters

Crawler $element

Return Value

bool

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Foundation/Testing/Constraints/HasElement.html