protected function MediaLibraryTestBase::waitForElementsCount in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::waitForElementsCount()
- 9 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::waitForElementsCount()
Checks for a specified number of specific elements on page after wait.
@todo replace with whatever gets added in https://www.drupal.org/node/3061852
Parameters
string $selector_type: Element selector type (css, xpath)
string|array $selector: Element selector.
int $count: Expected count.
int $timeout: Timeout in milliseconds, defaults to 10000.
File
- core/modules/ media_library/ tests/ src/ FunctionalJavascript/ MediaLibraryTestBase.php, line 104 
Class
- MediaLibraryTestBase
- Base class for functional tests of Media Library functionality.
Namespace
Drupal\Tests\media_library\FunctionalJavascriptCode
protected function waitForElementsCount($selector_type, $selector, $count, $timeout = 10000) {
  $page = $this
    ->getSession()
    ->getPage();
  $start = microtime(TRUE);
  $end = $start + $timeout / 1000;
  do {
    $nodes = $page
      ->findAll($selector_type, $selector);
    if (count($nodes) === $count) {
      return;
    }
    usleep(100000);
  } while (microtime(TRUE) < $end);
  $this
    ->assertSession()
    ->elementsCount($selector_type, $selector, $count);
}