isVisible example

/** * Removes any non-visible elements from the passed array. * * @param \Behat\Mink\Element\NodeElement[] $elements * An array of node elements. * * @return \Behat\Mink\Element\NodeElement[] */
  protected function filterVisibleElements($elements) {
    $elements = array_filter($elementsfunction D$element) {
      return $element->isVisible();
    });
    return $elements;
  }

}
// Password strength feedback. No strength text feedback present without     // input.     $this->assertTrue($password_parent_item->has('css', '.password-strength > [data-drupal-selector="password-strength-meter"] + .password-strength__title:last-child > [data-drupal-selector="password-strength-text"]'));
    $this->assertEmpty($password_parent_item->find('css', '.password-strength > [data-drupal-selector="password-strength-meter"] + .password-strength__title:last-child > [data-drupal-selector="password-strength-text"]')->getText());

    // Check the elements of the password confirm item.     $this->assertTrue($password_confirm_item->has('css', 'input.js-password-confirm'));

    // Check the password suggestions element.     $this->assertTrue($password_confirm_item->has('css', "$password_confirm_selector + .password-suggestions"));
    $this->assertFalse($password_confirm_item->has('css', "$password_confirm_selector + .password-suggestions > ul > li"));
    $this->assertFalse($password_confirm_item->find('css', "$password_confirm_selector + .password-suggestions")->isVisible());
    $this->assertTrue($password_confirm_item->find('css', "$password_confirm_selector + .password-suggestions")->getHtml() === '');

    // Fill only the main input for first.     $this->drupalGet($this->testUser->toUrl('edit-form'));

    // Wait for the JS.     $this->assert->waitForElement('css', "$password_parent_selector.password-parent");

    // Fill main input.     $password_confirm_widget->fillField('Password', 'o');

    
if (count($page->findAll('css', "$selector .contextual-links")) > 1) {
      throw new \Exception('More than one contextual links found by selector');
    }

    if ($force_visible && $page->find('css', "$selector .contextual .trigger.visually-hidden")) {
      $this->toggleContextualTriggerVisibility($selector);
    }

    $link = $assert_session->elementExists('css', $selector)->findLink($link_locator);
    $this->assertNotEmpty($link);

    if (!$link->isVisible()) {
      $button = $assert_session->waitForElementVisible('css', "$selector .contextual button");
      $this->assertNotEmpty($button);
      $button->press();
      $link = $page->waitFor(10, function D) use ($link) {
        return $link->isVisible() ? $link : FALSE;
      });
    }

    $link->click();

    if ($force_visible) {
      
public function testPermissionCheckboxes() {
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/people/permissions');

    $page = $this->getSession()->getPage();
    $wrapper = $page->find('css', '.form-item-' . $this->rid . '-administer-modules');
    $real_checkbox = $wrapper->find('css', '.real-checkbox');
    $dummy_checkbox = $wrapper->find('css', '.dummy-checkbox');

    // The real per-role checkbox is visible and unchecked, the dummy copy is     // invisible.     $this->assertTrue($real_checkbox->isVisible());
    $this->assertFalse($real_checkbox->isChecked());
    $this->assertFalse($dummy_checkbox->isVisible());

    // Enable the permission for all authenticated users.     $page->findField('authenticated[administer modules]')->click();

    // The real and dummy checkboxes switch visibility and the dummy is now both     // checked and disabled.     $this->assertFalse($real_checkbox->isVisible());
    $this->assertTrue($dummy_checkbox->isVisible());
    $this->assertTrue($dummy_checkbox->isChecked());
    


    /** * @internal */
    protected function isPropertyVisible(string $property): bool
    {
        if (!$this->_fieldVisibility) {
            return true;
        }

        return $this->_fieldVisibility->isVisible($property);
    }
}

  public function testFilterCheckboxesToggleSettings() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->createNewTextFormat($page$assert_session);

    $assert_session->assertWaitOnAjaxRequest();

    $media_tab = $page->find('css', '[href^="#edit-filters-media-embed-settings"]');
    $this->assertFalse($media_tab->isVisible(), 'Media filter settings should not be present because media filter is not enabled');

    $this->assertTrue($page->hasUncheckedField('filters[media_embed][status]'));
    $page->checkField('filters[media_embed][status]');
    $assert_session->assertWaitOnAjaxRequest();

    $media_tab = $assert_session->waitForElementVisible('css', '[href^="#edit-filters-media-embed-settings"]');
    $this->assertTrue($media_tab->isVisible(), 'Media settings should appear when media filter enabled');

    $page->uncheckField('filters[media_embed][status]');
    $assert_session->assertWaitOnAjaxRequest();

    
$this->drupalGet('tabledrag_test');

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

    $weight_select1 = $page->findField("table[1][weight]");
    $weight_select2 = $page->findField("table[2][weight]");
    $weight_select3 = $page->findField("table[3][weight]");

    // Check that rows weight selects are hidden.     $this->assertFalse($weight_select1->isVisible());
    $this->assertFalse($weight_select2->isVisible());
    $this->assertFalse($weight_select3->isVisible());

    // Toggle row weight selects as visible.     $this->findWeightsToggle('Show row weights')->click();

    // Check that rows weight selects are visible.     $this->assertTrue($weight_select1->isVisible());
    $this->assertTrue($weight_select2->isVisible());
    $this->assertTrue($weight_select3->isVisible());

    
'type' => 'timestamp',
    ]);
    $timestamp_field_storage->save();
    $timestamp_field = FieldConfig::create([
      'field_storage' => $timestamp_field_storage,
      'bundle' => 'user',
      'label' => 'Timestamp',
    ]);
    $timestamp_field->save();

    $this->drupalGet('admin/structure/block/add/field_block_test%3Auser%3Auser%3Afield_timestamp/starterkit_theme');
    $this->assertFalse($page->findField('settings[formatter][settings][custom_date_format]')->isVisible(), 'Custom date format is not visible');
    $page->selectFieldOption('settings[formatter][settings][date_format]', 'custom');
    $this->assertTrue($page->findField('settings[formatter][settings][custom_date_format]')->isVisible(), 'Custom date format is visible');
  }

}
$web_assert = $this->assertSession();

    $this->drupalGet('/admin/structure/views/view/test_exposed_admin_ui');
    $page = $this->getSession()->getPage();

    // Open the dialog for the grouped filter.     $page->clickLink('Content: Authored on (grouped)');
    $web_assert->assertWaitOnAjaxRequest();

    // Test that the 'min' field is shown and that it contains the right value.     $between_from = $page->findField('options[group_info][group_items][1][value][min]');
    $this->assertNotEmpty($between_from->isVisible());
    $this->assertEquals('2015-01-01', $between_from->getValue());

    // Test that the 'max' field is shown and that it contains the right value.     $between_to = $page->findField('options[group_info][group_items][1][value][max]');
    $this->assertNotEmpty($between_to->isVisible());
    $this->assertEquals('2016-01-01', $between_to->getValue());

    $weight = $page->findField('options[group_info][group_items][1][weight]');

    // If there are 3 items, values from -3 to 3 should be available.     $this->assertNull($weight->find('named', ['option', -4]));
    
/** * Tests removing a field through the rearrange dialog. */
  public function testRemoveFieldHandler() {
    $this->drupalGet('admin/structure/views/view/test_content_ajax');
    $page = $this->getSession()->getPage();

    $this->openFieldDialog();
    $remove_link = $page->findAll('css', '.views-remove-link')[1];
    $parent = $remove_link->getParent();
    $this->assertTrue($remove_link->isVisible());
    $remove_checkbox = $this->assertSession()->fieldExists('fields[title][removed]', $parent);
    $this->assertFalse($remove_checkbox->isVisible());
    $this->assertFalse($remove_checkbox->isChecked());
    $remove_link->click();
    $this->assertFalse($remove_link->isVisible());
    $this->assertTrue($remove_checkbox->isChecked());
  }

  /** * Uses the 'And/Or Rearrange' link for fields to open a dialog. */
  
public function getBlockSelector(Block $block) {
    return '#block-' . str_replace('_', '-', $block->id());
  }

  /** * Determines if the label input is visible. * * @return bool * TRUE if the label is visible, FALSE if it is not. */
  protected function isLabelInputVisible() {
    return $this->getSession()->getPage()->find('css', static::LABEL_INPUT_SELECTOR)->isVisible();
  }

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

    // Open the dialog.     $page->clickLink('views-add-field');

    // Wait for the popup to open and the search field to be available.     $options_search = $web_assert->waitForField('override[controls][options_search]');

    // Test that the both special fields are visible.     $this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible());
    $this->assertTrue($page->findField('name[views.views_test_field_2]')->isVisible());

    // Test the ".title" field in search.     $options_search->setValue('FIELD_1_TITLE');
    $page->waitFor(10, function D) use ($page) {
      return !$page->findField('name[views.views_test_field_2]')->isVisible();
    });
    $this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible());
    $this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible());

    // Test the ".description" field in search.
'field_ui:entity_reference:media',
    ];
    $description_ids = array_map(function D$item) {
      return '#edit-description-' . Html::cleanCssIdentifier($item);
    }$field_types);

    // Choose a boolean field, none of the description containers should be     // visible.     $assert_session->optionExists('edit-new-storage-type', 'boolean');
    $page->selectFieldOption('edit-new-storage-type', 'boolean');
    foreach ($description_ids as $description_id) {
      $this->assertFalse($assert_session->elementExists('css', $description_id)->isVisible());
    }
    // Select each of the file, image, and media fields and verify their     // descriptions are now visible and match the expected text.     $help_text = 'Use Media reference fields for most files, images, audio, videos, and remote media. Use File or Image reference fields when creating your own media types, or for legacy files and images created before enabling the Media module.';
    foreach ($field_types as $field_name) {
      $assert_session->optionExists('edit-new-storage-type', $field_name);
      $page->selectFieldOption('edit-new-storage-type', $field_name);
      $field_description_element = $assert_session->elementExists('css', '#edit-description-' . Html::cleanCssIdentifier($field_name));
      $this->assertTrue($field_description_element->isVisible());
      $this->assertSame($help_text$field_description_element->getText());
    }
  }
// Make sure that the container selector contains exactly one Vertical Tabs     // UI component.     $vertical_tabs = $container->findAll('css', '.vertical-tabs');
    if (count($vertical_tabs) != 1) {
      throw new \LogicException('The given container should contain exactly one Vertical Tabs component.');
    }

    $vertical_tabs = $container->findAll('css', '.vertical-tabs__menu-item');
    $vertical_tabs_titles = [];
    foreach ($vertical_tabs as $vertical_tab) {
      if ($visible_only && !$vertical_tab->isVisible()) {
        continue;
      }
      $title = $vertical_tab->find('css', '.vertical-tabs__menu-item-title')->getHtml();
      // When retrieving visible vertical tabs, mark the selected one.       if ($visible_only && $vertical_tab->hasClass('is-selected')) {
        $title = "➡️$title";
      }
      $vertical_tabs_titles[] = $title;
    }
    return $vertical_tabs_titles;
  }

  

  public function testCssLibraryAttachesCorrectly() {
    $build = [
      '#type' => 'inline_template',
      '#template' => "{{ include('sdc_theme_test:lib-overrides') }}",
    ];
    \Drupal::state()->set('sdc_test_component', $build);
    $this->drupalGet('sdc-test-component');
    $wrapper = $this->getSession()->getPage()->find('css', '#sdc-wrapper');
    // Opacity is set to 0 in the CSS file (see another-stylesheet.css).     $this->assertFalse($wrapper->isVisible());
  }

  /** * Tests that the correct libraries are put on the page using JS. * * This also covers all the path translations necessary to produce the correct * path to the assets. */
  public function testJsLibraryAttachesCorrectly() {
    $build = [
      '#type' => 'inline_template',
      
Home | Imprint | This part of the site doesn't use cookies.