. * */ use Behat\Behat\Context\Context; class NotificationContext implements Context, ActorAwareInterface { use ActorAware; /** * @return Locator */ public static function notificationMessage($message) { return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' toastify ') and normalize-space(text()) = '$message']")-> descendantOf(self::notificationContainer())-> describedAs("$message notification"); } /** * @return Locator */ private static function notificationContainer() { return Locator::forThe()->id("content")-> describedAs("Notification container"); } /** * @Then I see that the :message notification is shown */ public function iSeeThatTheNotificationIsShown($message) { PHPUnit_Framework_Assert::assertTrue($this->actor->find( self::notificationMessage($message), 10)->isVisible()); } }