Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser.php
Show All 13 Lines | |||||
{ | { | ||||
/** | /** | ||||
* Assert that the given element attribute contains specified text. | * Assert that the given element attribute contains specified text. | ||||
*/ | */ | ||||
public function assertAttributeRegExp($selector, $attribute, $regexp) | public function assertAttributeRegExp($selector, $attribute, $regexp) | ||||
{ | { | ||||
$element = $this->resolver->findOrFail($selector); | $element = $this->resolver->findOrFail($selector); | ||||
$value = (string) $element->getAttribute($attribute); | $value = (string) $element->getAttribute($attribute); | ||||
$error = "No expected text in [$selector][$attribute]. Found: $value"; | |||||
Assert::assertRegExp($regexp, $value, "No expected text in [$selector][$attribute]. Found: $value"); | Assert::assertMatchesRegularExpression($regexp, $value, $error); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Assert number of (visible) elements | * Assert number of (visible) elements | ||||
*/ | */ | ||||
public function assertElementsCount($selector, $expected_count, $visible = true) | public function assertElementsCount($selector, $expected_count, $visible = true) | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | class Browser extends \Laravel\Dusk\Browser | ||||
/** | /** | ||||
* Assert that the given element contains specified text, | * Assert that the given element contains specified text, | ||||
* no matter it's displayed or not - using a regular expression. | * no matter it's displayed or not - using a regular expression. | ||||
*/ | */ | ||||
public function assertTextRegExp($selector, $regexp) | public function assertTextRegExp($selector, $regexp) | ||||
{ | { | ||||
$element = $this->resolver->findOrFail($selector); | $element = $this->resolver->findOrFail($selector); | ||||
Assert::assertRegExp($regexp, $element->getText(), "No expected text in [$selector]"); | Assert::assertMatchesRegularExpression($regexp, $element->getText(), "No expected text in [$selector]"); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Remove all toast messages | * Remove all toast messages | ||||
*/ | */ | ||||
public function clearToasts() | public function clearToasts() | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |