assertElementVisibleAfterWait example

$this->drupalGet('admin');

    // Wait for toolbar to appear.     $this->assertNotEmpty($assert_session->waitForElement('css', 'body.toolbar-horizontal'));

    // Open workspace canvas.     $page->clickLink('Switch workspace');
    $this->waitForOffCanvasToOpen('top');

    // Click 'stage' workspace and confirm switch.     $page->clickLink('Stage');
    $this->assertElementVisibleAfterWait('css', '.workspace-activate-form.workspace-confirm-form');
    $page->find('css', '.ui-dialog-buttonset .button--primary')->click();
    $assert_session->statusMessageContainsAfterWait('Stage is now the active workspace.', 'status');
    // Make sure we stay on same page after switch.     $assert_session->addressEquals('admin');
  }

}
$this->assertStringContainsString("/admin/structure/block/manage/$block_id/settings-tray?destination=$destination", $link->getAttribute('href'));

    if (isset($toolbar_item)) {
      // Check that you can open a toolbar tray and it will be closed after       // entering edit mode.       if ($element = $page->find('css', "#toolbar-administration a.is-active")) {
        // If a tray was open from page load close it.         $element->click();
        $web_assert->assertNoElementAfterWait('css', "#toolbar-administration a.is-active");
      }
      $page->find('css', $toolbar_item)->click();
      $this->assertElementVisibleAfterWait('css', "{$toolbar_item}.is-active");
    }
    $this->enableEditMode();
    if (isset($toolbar_item)) {
      $web_assert->assertNoElementAfterWait('css', "{$toolbar_item}.is-active");
    }
    $this->openBlockForm($block_selector);
    switch ($block_plugin) {
      case 'system_powered_by_block':
        // Confirm "Display Title" is not checked.         $web_assert->checkboxNotChecked('settings[label_display]');
        // Confirm Title is not visible.
// Confirm that System Branding block does not expose Site Name field     // without permission.     $block = $this->placeBlock('system_branding_block');
    $this->drupalGet('user');
    $this->enableEditMode();
    $this->openBlockForm($this->getBlockSelector($block));
    // The site name field should not appear because the user doesn't have     // permission.     $web_assert->fieldNotExists('settings[site_information][site_name]');
    $page->pressButton('Save Site branding');
    $this->waitForOffCanvasToClose();
    $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
    $web_assert->assertWaitOnAjaxRequest();
    // Confirm we did not save changes to the configuration.     $this->assertEquals('Drupal', \Drupal::configFactory()->getEditable('system.site')->get('name'));

    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID)['administer site configuration']);
    $this->drupalGet('user');
    $this->openBlockForm($this->getBlockSelector($block));
    // The site name field should appear because the user does have permission.     $web_assert->fieldExists('settings[site_information][site_name]');

    // Confirm that the Menu block does not expose menu configuration without

  protected function openBlockForm($block_selector$contextual_link_container = '') {
    if (!$contextual_link_container) {
      $contextual_link_container = $block_selector;
    }
    // Ensure that contextual link element is present because this is required     // to open the off-canvas dialog in edit mode.     $contextual_link = $this->assertSession()->waitForElement('css', "$contextual_link_container .contextual-links a");
    $this->assertNotEmpty($contextual_link);
    // When page first loads Edit Mode is not triggered until first contextual     // link is added.     $this->assertElementVisibleAfterWait('css', '.dialog-off-canvas-main-canvas.js-settings-tray-edit-mode');
    // Ensure that all other Ajax activity is completed.     $this->assertSession()->assertWaitOnAjaxRequest();
    $block = $this->getSession()->getPage()->find('css', $block_selector);
    $block->mouseOver();
    $block->click();
    $this->waitForOffCanvasToOpen();
    $this->assertOffCanvasBlockFormIsValid();
  }

  /** * Enables edit mode by pressing edit button in the toolbar. */
$this->drupalGet('user');
    $this->enableEditMode();
    $this->openBlockForm($this->getBlockSelector($branding_block));
    $web_assert->fieldExists('settings[site_information][site_name]');
    // Confirm the branding block does not include 'site_information' section     // when the site name is overridden.     $this->container->get('state')->set('settings_tray_override_test.site_name', TRUE);
    $this->drupalGet('user');
    $this->openBlockForm($this->getBlockSelector($branding_block));
    $web_assert->fieldNotExists('settings[site_information][site_name]');
    $page->pressButton('Save Site branding');
    $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
    $web_assert->assertWaitOnAjaxRequest();
    // Confirm we did not save changes to the configuration.     $this->assertEquals('Llama Fan Club', \Drupal::configFactory()->get('system.site')->get('name'));
    $this->assertEquals('Drupal', \Drupal::configFactory()->getEditable('system.site')->get('name'));

    // Add a link or the menu will not render.     $menu_link_content = MenuLinkContent::create([
      'title' => 'This is on the menu',
      'menu_name' => 'main',
      'link' => ['uri' => 'route:<front>'],
    ]);
    
Home | Imprint | This part of the site doesn't use cookies.