You are here

protected function LingotekSourceActionsTest::waitForVisibleElementCount in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 4.0.x tests/src/FunctionalJavascript/LingotekSourceActionsTest.php \Drupal\Tests\lingotek\FunctionalJavascript\LingotekSourceActionsTest::waitForVisibleElementCount()

Waits for the specified number of items to be visible.

Parameters

int $count: The number of found elements to wait for.

string|array $locator: The selector locator.

int $timeout: (Optional) Timeout in milliseconds, defaults to 10000.

Return value

bool TRUE if the required number was matched, FALSE otherwise.

1 call to LingotekSourceActionsTest::waitForVisibleElementCount()
LingotekSourceActionsTest::testDropdownSourceStatus in tests/src/FunctionalJavascript/LingotekSourceActionsTest.php

File

tests/src/FunctionalJavascript/LingotekSourceActionsTest.php, line 110

Class

LingotekSourceActionsTest
@group lingotek

Namespace

Drupal\Tests\lingotek\FunctionalJavascript

Code

protected function waitForVisibleElementCount($count, $locator, $timeout = 10000) {
  $page = $this
    ->getSession()
    ->getPage();
  return $page
    ->waitFor($timeout / 1000, function () use ($count, $page, $locator) {
    $elements = $page
      ->findAll('css', $locator);
    $visible_elements = $this
      ->filterVisibleElements($elements);
    if (count($visible_elements) === $count) {
      return TRUE;
    }
    return FALSE;
  });
}