waitForText example

$assert_session->elementNotExists('css', '.tabledrag-changed-warning');
    $assert_session->elementNotExists('css', 'abbr.tabledrag-changed');
    $page->selectFieldOption('fields[uid][type]', 'options_buttons');
    $this->assertNotNull($changed_warning = $assert_session->waitForElementVisible('css', '.tabledrag-changed-warning'));
    $this->assertNotNull($assert_session->waitForElementVisible('css', ' #uid abbr.tabledrag-changed'));
    $this->assertSame('* You have unsaved changes.', $changed_warning->getText());

    // Form display, change widget settings.     $this->drupalGet($manage_form);
    $edit_widget_button = $assert_session->waitForElementVisible('css', '[data-drupal-selector="edit-fields-uid-settings-edit"]');
    $edit_widget_button->press();
    $assert_session->waitForText('3rd party formatter settings form');

    // Confirm the AJAX operation of opening the form does not result in the row     // being set as changed. New settings must be submitted for that to happen.     $assert_session->elementNotExists('css', 'abbr.tabledrag-changed');
    $cancel_button = $assert_session->waitForElementVisible('css', '[data-drupal-selector="edit-fields-uid-settings-edit-form-actions-cancel-settings"]');
    $cancel_button->press();
    $assert_session->assertNoElementAfterWait('css', '[data-drupal-selector="edit-fields-uid-settings-edit-form-actions-cancel-settings"]');
    $assert_session->elementNotExists('css', '.tabledrag-changed-warning');
    $assert_session->elementNotExists('css', 'abbr.tabledrag-changed');
    $edit_widget_button = $assert_session->waitForElementVisible('css', '[data-drupal-selector="edit-fields-uid-settings-edit"]');
    $edit_widget_button->press();
    

  public function testBookAddOutline() {
    $this->drupalLogin($this->drupalCreateUser(['create book content', 'create new books', 'add content to books']));
    $this->drupalGet('node/add/book');
    $assert_session = $this->assertSession();
    $session = $this->getSession();
    $page = $session->getPage();

    $page->find('css', '#edit-book')->click();
    $book_select = $page->findField("book[bid]");
    $book_select->setValue('new');
    $assert_session->waitForText('This will be the top-level page in this book.');
    $assert_session->pageTextContains('This will be the top-level page in this book.');
    $assert_session->pageTextNotContains('No book selected.');
    $book_select->setValue(0);
    $assert_session->waitForText('No book selected.');
    $assert_session->pageTextContains('No book selected.');
    $assert_session->pageTextNotContains('This will be the top-level page in this book.');
  }

}
    // form is not triggered.     $assert_session->pageTextNotContains('Title field is required.');

    $this->assertTrue($menu->hasLink('Type One'));
    $this->assertTrue($menu->hasLink('Type Two'));
    $this->assertTrue($menu->hasLink('Type Three'));
    $this->assertTrue($menu->hasLink('Type Four'));
    $this->assertTrue($menu->hasLink('Type Five'));

    // Insert media to test validation with null target_bundles.     $this->switchToMediaType('One');
    $this->assertNotEmpty($assert_session->waitForText('Showing Type One media.'));
    $this->selectMediaItem(0);
    $this->pressInsertSelected('Added one media item.');

    // Assert that the media type menu is not available when only 1 type is     // configured for the field.     $this->openMediaLibraryForField('field_single_media_type', '#media-library-wrapper');
    $this->waitForElementTextContains('.media-library-selected-count', '0 of 1 item selected');

    // Select a media item, assert the hidden selection field contains the ID of     // the selected item.     $this->selectMediaItem(0);
    
/** * Tests that editor selection can be toggled without breaking ajax. */
  public function testEditorSelection() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('/admin/config/content/formats/add');
    $page->fillField('name', 'Sulaco');
    // Wait for machine name to be filled in.     $this->assertNotEmpty($assert_session->waitForText('sulaco'));
    $page->selectFieldOption('editor[editor]', 'unicorn');
    $this->assertNotEmpty($this->assertSession()->waitForField('editor[settings][ponies_too]'));
    $page->pressButton('Save configuration');

    // Test that toggling the editor selection off and back on works.     $this->drupalGet('/admin/config/content/formats/manage/sulaco');
    // Deselect and reselect an editor.     $page->selectFieldOption('editor[editor]', '');
    $this->assertNotEmpty($this->assertSession()->waitForElementRemoved('named', ['field', 'editor[settings][ponies_too]']));
    $page->selectFieldOption('editor[editor]', 'unicorn');
    $this->assertNotEmpty($this->assertSession()->waitForField('editor[settings][ponies_too]'));
  }
foreach ($media_items as $media_item) {
      $media_names[] = $media_item->getText();
    }
    sort($media_names);
    // cSpell:disable-next-line     $this->assertSame(['Ardilla', 'Eekhoorn', 'Hert', 'Tejón', 'Vos', 'Zorro']$media_names);

    // All media should only be shown once, and should be shown in the interface     // language.     $this->drupalGet('nl/node/add/article');
    $assert_session->elementExists('css', '.js-media-library-open-button[name^="field_media"]')->click();
    $assert_session->waitForText('Add or select media');
    $assert_session->elementsCount('css', '.js-media-library-item', 4);
    $media_items = $page->findAll('css', '.js-media-library-item-preview + div');
    $media_names = [];
    foreach ($media_items as $media_item) {
      $media_names[] = $media_item->getText();
    }
    sort($media_names);
    // cSpell:disable-next-line     $this->assertSame(['Eekhoorn', 'Hert', 'Tejón', 'Vos']$media_names);

    $this->drupalGet('es/node/add/article');
    

    else {
      $this->pressSaveButton();
    }

    if ($selected_operation !== 'insert') {
      $this->pressInsertSelected();
    }
    // There should not be any warnings or errors.     $assert_session->elementNotExists('css', '.messages--error');
    $assert_session->elementNotExists('css', '.messages--warning');
    $this->waitForText('Added 5 media items.');
  }

  /** * Data provider for ::testWidgetOverflow() and ::testUnlimitedCardinality(). * * @return array[] * Sets of arguments to pass to the test method. */
  public function providerWidgetOverflow(): array {
    return [
      'Save' => [NULL],
      
$node->save();

    $this->drupalGet('admin/content');

    $page->find('css', '.dropbutton-toggle button')->click();
    $page->clickLink('Delete');

    // Asserts a dialog opens with the expected text.     $this->assertEquals('Are you sure you want to delete the content item Delete article from content list?', $assert_session->waitForElement('css', '.ui-dialog-title')->getText());
    $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete');

    $assert_session->waitForText('The Article Delete article from content list has been deleted.');
    // Assert that the node is deleted in above operation.     $this->drupalGet('/admin/content');
    $assert_session->waitForText('There are no content items yet.');

    $node = $this->createNode([
      'type' => 'article',
      'title' => 'Delete article from entity form',
    ]);
    $node->save();

    // Tests the delete modal on its entity form.
    // result in a 200 response (due to server error or network error) is     // handled in the JavaScript by displaying the expected error message.     // @see core/modules/media/js/media_embed_ckeditor.theme.js     // @see js/ckeditor5_plugins/drupalMedia/src/drupalmediaediting.js     $this->container->get('state')->set('test_media_filter_controller_throw_error', TRUE);
    $this->drupalGet($this->host->toUrl('edit-form'));
    $this->waitForEditor();
    $assert_session = $this->assertSession();
    $assert_session->waitForElementVisible('css', '.ck-widget.drupal-media');
    $this->assertEmpty($assert_session->waitForElementVisible('css', 'img[src*="image-test.png"]', 1000));
    $assert_session->elementNotExists('css', '.ck-widget.drupal-media .media');
    $this->assertNotEmpty($assert_session->waitForText('An error occurred while trying to preview the media. Please save your work and reload this page.'));
    // Now assert that the error doesn't appear when the override to force an     // error is removed.     $this->container->get('state')->set('test_media_filter_controller_throw_error', FALSE);
    $this->getSession()->reload();
    $this->waitForEditor();
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', 'img[src*="image-test.png"]'));

    // There's a second kind of error message that comes from the back end     // that happens when the media uuid can't be converted to a media preview.     // In this case, the error will appear in a the themeable     // media-embed-error.html template. We have a hook altering the css
$assert_session->assertWaitOnAjaxRequest();

    // Check that the drag-triggered rebuild did not trigger content preview.     $assert_session->pageTextNotContains($content_preview_body_text);

    // Check that drag successfully repositioned blocks.     $this->assertOrderInPage([$body_field_placeholder_label$links_field_placeholder_label]);

    // Check if block position maintained after enabling content preview.     $this->assertTrue($page->hasUncheckedField('layout-builder-content-preview'));
    $page->checkField('layout-builder-content-preview');
    $this->assertNotEmpty($assert_session->waitForText($content_preview_body_text));
    $assert_session->pageTextContains($content_preview_body_text);
    $this->assertNotEmpty($assert_session->waitForText('Placeholder for the "Links" field'));
    $this->assertOrderInPage([$content_preview_body_text, 'Placeholder for the "Links" field']);
  }

  /** * Checks if contextual links are working properly. * * @internal */
  protected function assertContextualLinks(): void {
    
$this->assertTrue($filtering_done);

    // Select the body field and apply the choice.     $page->checkField('name[node__body.body_value]');
    $page->find('css', '.ui-dialog .ui-dialog-buttonpane')->pressButton('Add and configure filter criteria');
    $web_assert->waitForField('options[expose_button][checkbox][checkbox]');

    // Expose the filter.     $page->findField('options[expose_button][checkbox][checkbox]')->click();
    $web_assert->waitForField('options[expose][label]');
    $page->find('css', '.ui-dialog .ui-dialog-buttonpane')->pressButton('Apply');
    $web_assert->waitForText('Content: body (exposed)');
    $web_assert->responseContains('Content: body (exposed)');
  }

  /** * Removes any non-visible elements from the passed array. * * @param \Behat\Mink\Element\NodeElement[] $elements * The elements to filter. * * @return \Behat\Mink\Element\NodeElement[] * The filtered elements. */
// Assert the default formatter configuration.     $assert_session->fieldValueEquals('settings[formatter][type]', 'datetime_default');
    $assert_session->fieldValueEquals('settings[formatter][settings][format_type]', 'medium');

    // Change the formatter.     $page->selectFieldOption('settings[formatter][type]', 'datetime_time_ago');
    $assert_session->assertWaitOnAjaxRequest();
    // Changing the formatter removes the old settings and introduces new ones.     $assert_session->fieldNotExists('settings[formatter][settings][format_type]');
    $assert_session->fieldExists('settings[formatter][settings][granularity]');
    $page->pressButton('Save block');
    $this->assertTrue($assert_session->waitForText('The block configuration has been saved.'));

    // Configure the block and change the formatter again.     $this->clickLink('Configure');
    $page->selectFieldOption('settings[formatter][type]', 'datetime_default');
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->fieldValueEquals('settings[formatter][settings][format_type]', 'medium');
    $page->selectFieldOption('settings[formatter][settings][format_type]', 'long');

    $page->pressButton('Save block');
    $this->assertTrue($assert_session->waitForText('The block configuration has been saved.'));

    
$result = $page->findButton('Added WaitForElementVisible');
    $this->assertEmpty($result);
    $test_wait_on_element_visible->click();
    $result = $assert_session->waitForElementVisible('named', ['button', 'Added WaitForElementVisible']);
    $this->assertNotEmpty($result);
    $this->assertInstanceOf(NodeElement::class$result);
    $this->assertEquals(TRUE, $result->isVisible());

    $this->drupalGet('js_webassert_test_page');
    // Ensure that the javascript has replaced the element 1100 times.     $assert_session->waitForText('New Text!! 1100');
    $result = $page->find('named', ['id', 'test_text']);
    $this->assertSame('test_text', $result->getAttribute('id'));
  }

}
$assert_session->assertWaitOnAjaxRequest();

    // The image upload settings form should now be present.     $assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-image"]');

    $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-active .ckeditor5-toolbar-item-drupalInsertImage'));

    // The image insert plugin is enabled and inserting <img> is allowed.     $this->assertEquals($this->allowedElements . ' <img src alt height width>', $allowed_html_field->getValue());

    $page->clickLink('Image');
    $assert_session->waitForText('Enable image uploads');
    $this->assertTrue($page->hasUncheckedField('editor[settings][plugins][ckeditor5_image][status]'));
    $page->checkField('editor[settings][plugins][ckeditor5_image][status]');
    $assert_session->assertWaitOnAjaxRequest();

    // Enabling image uploads adds <img> with several attributes to allowed     // tags.     $this->assertEquals($this->allowedElements . ' <img src alt height width data-entity-uuid data-entity-type>', $allowed_html_field->getValue());

    // Also enabling the caption filter will add the data-caption attribute to     // <img>.     $this->assertTrue($page->hasUncheckedField('filters[filter_caption][status]'));
    

  public function testWarningFilterUi($theme$expected_warning) {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();
    $this->addNewTextFormat($page$assert_session);
    $this->drupalGet('admin/config/content/formats/manage/ckeditor5');

    $assert_session->pageTextNotContains($expected_warning);
    $this->installThemeThatTriggersWarning($theme);
    $this->drupalGet('admin/config/content/formats/manage/ckeditor5');
    $this->assertTrue($assert_session->waitForText($expected_warning));
  }

  /** * Data provider for testWarningFilterUI(). * * @return string[][] * An array with the theme to enable and the warning message to check. */
  public function providerTestWarningFilterUi() {
    return [
      'single theme' => [
        

  protected function waitForText($text$timeout = 10000) {
    $result = $this->assertSession()->waitForText($text$timeout);
    $this->assertNotEmpty($result, "\"$text\" not found");
  }

  /** * Asserts that text does not appear on page after a wait. * * @param string $text * The text that should not be on the page. * @param int $timeout * Timeout in milliseconds, defaults to 10000. * * @todo replace with whatever gets added in * https://www.drupal.org/node/3061852 */
Home | Imprint | This part of the site doesn't use cookies.