Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser.php
Show First 20 Lines • Show All 113 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. | * no matter it's displayed or not. | ||||
*/ | */ | ||||
public function assertText($selector, $text) | public function assertText($selector, $text) | ||||
{ | { | ||||
$element = $this->resolver->findOrFail($selector); | $element = $this->resolver->findOrFail($selector); | ||||
if ($text === '') { | |||||
Assert::assertTrue((string) $element->getText() === $text, "Element's text is not empty [$selector]"); | |||||
} else { | |||||
Assert::assertTrue(strpos($element->getText(), $text) !== false, "No expected text in [$selector]"); | Assert::assertTrue(strpos($element->getText(), $text) !== false, "No expected text in [$selector]"); | ||||
} | |||||
return $this; | |||||
} | |||||
/** | |||||
* Assert that the given element contains specified text, | |||||
* no matter it's displayed or not - using a regular expression. | |||||
*/ | |||||
public function assertTextRegExp($selector, $regexp) | |||||
{ | |||||
$element = $this->resolver->findOrFail($selector); | |||||
Assert::assertRegExp($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 98 Lines • Show Last 20 Lines |