filterVisibleElements example


  protected function waitForVisibleElementCount($count$locator$timeout = 10000) {
    $page = $this->getSession()->getPage();

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

  /** * Waits for only content rows to be visible. * * @param int $timeout * (Optional) Timeout in milliseconds, defaults to 10000. * * @return bool * TRUE if the required number was matched, FALSE otherwise. */
$session = $this->getSession();
    $page = $session->getPage();

    $filter = $page->findField('edit-text');

    // Get all module rows, for assertions later.     $module_rows = $page->findAll('css', '.module-name');

    // Test module filter reduces the number of visible rows.     $filter->setValue('dynamic');
    $session->wait(1000, 'jQuery("#edit-uninstall-page-cache:visible").length == 0');
    $visible_rows = $this->filterVisibleElements($module_rows);
    $this->assertNotEquals(count($module_rows)count($visible_rows));

    // Test Drupal.announce() message when multiple matches are expected.     $filter->setValue('cache');
    $session->wait(1000, 'jQuery("#drupal-live-announce").html().indexOf("modules are available") > -1');
    $visible_rows = $this->filterVisibleElements($module_rows);
    $expected_message = count($visible_rows) . ' modules are available in the modified list.';
    $assertSession->elementTextContains('css', '#drupal-live-announce', $expected_message);

    // Test Drupal.announce() message when only one match is expected.     // Using a very specific module name, we expect only one row.
$disabled_views_count = 2;
    $content_views_count = 3;

    $this->drupalGet('admin/structure/views');

    $session = $this->assertSession();

    $page = $this->getSession()->getPage();

    // Test that we search in both the enabled and disabled rows.     $enabled_rows = $page->findAll('css', 'tr.views-ui-list-enabled');
    $enabled_rows = $this->filterVisibleElements($enabled_rows);
    $disabled_rows = $page->findAll('css', 'tr.views-ui-list-disabled');
    $disabled_rows = $this->filterVisibleElements($disabled_rows);

    // Test that we see some rows of views in both tables.     $this->assertCount($enabled_views_count$enabled_rows);
    $this->assertCount($disabled_views_count$disabled_rows);

    // Filter on the string 'people'. This should only show the people view.     $search_input = $page->find('css', '.views-filter-text.form-search');
    $search_input->setValue('people');

    
    $blocks = $page->findAll('css', '.js-layout-builder-categories li');
    $categories = $page->findAll('css', '.js-layout-builder-category');

    $filter = $assert_session->elementExists('css', '.js-layout-builder-filter');

    // Set announce to ensure it is not cleared.     $init_message = 'init message';
    $session->evaluateScript("Drupal.announce('$init_message')");
    // Test block filter does not take effect for 1 character.     $filter->setValue('a');
    $this->assertAnnounceContains($init_message);
    $visible_rows = $this->filterVisibleElements($blocks);
    $this->assertSameSize($blocks$visible_rows);

    // Get the Content Fields category, which will be closed before filtering.     $contentFieldsCategory = $page->find('named', ['content', 'Content fields']);
    // Link that belongs to the Content Fields category, to verify collapse.     $promoteToFrontPageLink = $page->find('named', ['content', 'Promoted to front page']);
    // Test that front page link is visible until Content Fields collapsed.     $this->assertTrue($promoteToFrontPageLink->isVisible());
    $contentFieldsCategory->click();
    $this->assertFalse($promoteToFrontPageLink->isVisible());

    
$session = $this->getSession();
    $page = $session->getPage();

    $filter = $page->findField('edit-text');

    // Get all module rows, for assertions later.     $module_rows = $page->findAll('css', '.package-listing tbody tr td.module');

    // Test module filter reduces the number of visible rows.     $filter->setValue('test');
    $session->wait(1000, 'jQuery("#module-node:visible").length == 0');
    $visible_rows = $this->filterVisibleElements($module_rows);
    // Test Drupal.announce() message when multiple matches are expected.     $expected_message = count($visible_rows) . ' modules are available in the modified list.';
    $assertSession->elementTextContains('css', '#drupal-live-announce', $expected_message);
    self::assertGreaterThan(count($visible_rows)count($module_rows));
    self::assertGreaterThan(1, count($visible_rows));

    // Test Drupal.announce() message when one match is expected.     // Using a very specific module name, we expect only one row.     $filter->setValue('System dependency test');
    $session->wait(1000, 'jQuery("#module-node:visible").length == 0');
    $visible_rows = $this->filterVisibleElements($module_rows);
    
// Find the block filter field on the add-block dialog.     $page->find('css', '#edit-blocks-region-header-title')->click();
    $filter = $assertSession->waitForElement('css', '.block-filter-text');

    // Get all block rows, for assertions later.     $block_rows = $page->findAll('css', '.block-add-table tbody tr');

    // Test block filter reduces the number of visible rows.     $filter->setValue('ad');
    $session->wait(10000, 'jQuery("#drupal-live-announce").html().indexOf("blocks are available") > -1');
    $visible_rows = $this->filterVisibleElements($block_rows);
    if (count($block_rows) > 0) {
      $this->assertNotSameSize($block_rows$visible_rows);
    }

    // Test Drupal.announce() message when multiple matches are expected.     $expected_message = count($visible_rows) . ' blocks are available in the modified list.';
    $assertSession->elementTextContains('css', '#drupal-live-announce', $expected_message);

    // Test Drupal.announce() message when only one match is expected.     $filter->setValue('Powered by');
    $session->wait(10000, 'jQuery("#drupal-live-announce").html().indexOf("block is available") > -1');
    
Home | Imprint | This part of the site doesn't use cookies.