You are here

public function PermissionsByTermDrupalSubContext::iShouldSeeTextAfterAWhile in Permissions by Term 8.2

@Then /^I should see text matching "([^"]*)" after a while$/

File

tests/src/Behat/Context/permissions_by_term.behat.inc, line 240

Class

PermissionsByTermDrupalSubContext
Class PermissionsByTermContext

Namespace

Drupal\Tests\permissions_by_term\Behat\PermissionsByTermDrupalSubContext

Code

public function iShouldSeeTextAfterAWhile($text) {
  try {
    $startTime = time();
    do {
      $content = $this
        ->getSession()
        ->getPage()
        ->getText();
      if (substr_count($content, $text) > 0) {
        return true;
      }
    } while (time() - $startTime < self::MAX_DURATION_SECONDS);
    throw new ResponseTextException(sprintf('Could not find text %s after %s seconds', $text, self::MAX_DURATION_SECONDS), $this
      ->getSession());
  } catch (StaleElementReference $e) {
    return true;
  }
}