elementTextNotContains example

// Turn just the site slogan off.     $this->config('block.block.site-branding')
      ->set('settings.use_site_name', 1)
      ->set('settings.use_site_slogan', 0)
      ->save();
    $this->drupalGet('');

    // Re-test all branding elements.     $this->assertSession()->elementExists('xpath', $site_logo_xpath);
    $this->assertSession()->elementExists('xpath', $site_name_xpath);
    $this->assertSession()->elementTextNotContains('xpath', $site_slogan_xpath, 'Community carpentry');
    $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:system.site');

    // Turn the site name and the site slogan off.     $this->config('block.block.site-branding')
      ->set('settings.use_site_name', 0)
      ->set('settings.use_site_slogan', 0)
      ->save();
    $this->drupalGet('');

    // Re-test all branding elements.     $this->assertSession()->elementExists('xpath', $site_logo_xpath);
    
$this->drupalGet($form->toUrl('canonical'));
    $this->submitForm($edit, 'Preview');
    // 'Message' should only be displayed once now with the actual message     // displayed twice.     $this->assertSession()->pageTextContainsOnce('Message');
    $this->assertSession()->pageTextMatchesCount(2, '/' . $message . '/');
    // Check for label and message in form element.     $this->assertSession()->elementTextEquals('css', 'label[for="edit-message-0-value"]', 'Message');
    $this->assertSession()->fieldValueEquals('edit-message-0-value', $message);
    // Check for message in preview but no label.     $this->assertSession()->elementTextNotContains('css', '#edit-preview', 'Message');
    $this->assertSession()->elementTextContains('css', '#edit-preview', $message);

    // Set the preview field to 'hidden' in the view mode and check that the     // field is hidden.     $edit = [
      'fields[preview][region]' => 'hidden',
    ];
    $this->drupalGet('admin/structure/contact/manage/' . $contact_form . '/form-display');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->fieldExists('fields[preview][region]');

    
'create basic_page content',
      'create media',
      'view media',
    ]);
    $this->drupalLogin($user);

    $default_message = 'There are no allowed media types configured for this field. Please contact the site administrator.';

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

    // Assert a properly configured field does not show a message.     $assert_session->elementTextNotContains('css', '.field--name-field-twin-media', 'There are no allowed media types configured for this field.');
    $assert_session->elementExists('css', '.js-media-library-open-button[name^="field_twin_media"]');
    // Assert that the message is shown when the target_bundles setting for the     // entity reference field is an empty array. No types are allowed in this     // case.     $assert_session->elementTextContains('css', '.field--name-field-empty-types-media', $default_message);
    $assert_session->elementNotExists('css', '.js-media-library-open-button[name^="field_empty_types_media"]');
    // Assert that the message is not shown when the target_bundles setting for     // the entity reference field is null. All types are allowed in this case.     $assert_session->elementTextNotContains('css', '.field--name-field-null-types-media', 'There are no allowed media types configured for this field.');
    $assert_session->elementExists('css', '.js-media-library-open-button[name^="field_null_types_media"]');

    
// Trigger the autocomplete.     $page = $this->getSession()->getPage();
    $autocomplete_field = $page->findField($field_name . '[0][target_id]');
    $autocomplete_field->setValue('dark');
    $this->getSession()->getDriver()->keyDown($autocomplete_field->getXpath(), ' ');
    $this->assertSession()->waitOnAutocomplete();

    // Check the autocomplete results.     $results = $page->findAll('css', '.ui-autocomplete li');
    $this->assertCount(1, $results);
    $this->assertSession()->elementTextNotContains('css', '.ui-autocomplete li', 'dark green');
    $this->assertSession()->elementTextContains('css', '.ui-autocomplete li', 'dark blue');
  }

  /** * Executes an autocomplete on a given field and waits for it to finish. * * @param string $field_name * The field name. */
  protected function doAutocomplete($field_name) {
    $autocomplete_field = $this->getSession()->getPage()->findField($field_name . '[0][target_id]');
    
    $tempstore = \Drupal::service('tempstore.private')->get('entity_delete_multiple_confirm');
    $tempstore->set($this->account->id() . ':entity_test_mulrevpub', $selection);

    $this->drupalGet('/entity_test/delete');
    $assert = $this->assertSession();
    $assert->statusCodeEquals(200);
    $assert->elementTextContains('css', 'h1', 'Are you sure you want to delete these test entity - revisions, data table, and published interface entities?');
    $list_selector = '#entity-test-mulrevpub-delete-multiple-confirm-form > ul[data-drupal-selector="edit-entities"]';
    $assert->elementTextContains('css', $list_selector, 'entity1 (Original translation) - The following test entity - revisions, data table, and published interface translations will be deleted:');
    $assert->elementTextContains('css', $list_selector, 'entity2 spanish');
    $assert->elementTextContains('css', $list_selector, 'entity2 french');
    $assert->elementTextNotContains('css', $list_selector, 'entity3 spanish');
    $assert->elementTextContains('css', $list_selector, 'entity3 french');
    $delete_button = $this->getSession()->getPage()->findButton('Delete');
    $delete_button->click();
    $assert = $this->assertSession();
    $assert->addressEquals('/user/' . $this->account->id());
    $assert->responseContains('Deleted 6 items.');
    $assert->responseContains('1 item has not been deleted because you do not have the necessary permissions.');

    \Drupal::entityTypeManager()->getStorage('entity_test_mulrevpub')->resetCache();
    $remaining_entities = EntityTestMulRevPub::loadMultiple([$entity1->id()$entity2->id()$entity3->id()$entity4->id()]);
    $this->assertCount(3, $remaining_entities);
  }


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

    foreach ($nodes as $node) {
      $file = File::load($node->file->target_id);
      $this->assertSession()->pageTextContains($file->getFilename());
      $this->assertSession()->linkByHrefExists($file->createFileUrl());
      $this->assertSession()->linkByHrefExists('admin/content/files/usage/' . $file->id());
      $this->assertSession()->linkByHrefExists($file->toUrl('delete-form')->toString());
    }
    $this->assertSession()->elementTextNotContains('css', '.views-element-container table', 'Temporary');
    $this->assertSession()->elementTextContains('css', '.views-element-container table', 'Permanent');

    // Use one file two times and check usage information.     $orphaned_file = $nodes[1]->file->target_id;
    $used_file = $nodes[0]->file->target_id;
    $nodes[1]->file->target_id = $used_file;
    $nodes[1]->save();

    $this->drupalGet('admin/content/files');
    $file = File::load($orphaned_file);
    $usage = $this->sumUsages($file_usage->listUsage($file));
    
$display_name = $user->getDisplayName();
    $this->drupalLogin($user);

    $this->drupalGet('big_pipe_test_preview');

    // This test begins with the big_pipe_bypass_js module enabled, which blocks     // Big Pipe's JavaScript from loading. Without that JavaScript, the     // placeholder and previews are not replaced and we can reliably test their     // presence.     $this->assertSession()->elementExists('css', '#placeholder-preview-twig-container [data-big-pipe-placeholder-id] > .i-am-taking-up-space');
    $this->assertSession()->elementTextEquals('css', '#placeholder-preview-twig-container [data-big-pipe-placeholder-id] > .i-am-taking-up-space', 'LOOK AT ME I AM CONSUMING SPACE FOR LATER');
    $this->assertSession()->elementTextNotContains('css', '#placeholder-preview-twig-container', $display_name);

    $this->assertSession()->pageTextContains('There is a lamb and there is a puppy');
    $this->assertSession()->elementTextEquals('css', '#placeholder-render-array-container [data-big-pipe-placeholder-id] > #render-array-preview', 'There is a lamb and there is a puppy');
    $this->assertSession()->elementTextNotContains('css', '#placeholder-render-array-container', 'Yarhar llamas forever!');

    // Uninstall big_pipe_bypass_js.     \Drupal::service('module_installer')->uninstall(['big_pipe_bypass_js']);
    $this->rebuildAll();
    $this->drupalGet('big_pipe_test_preview');
    $this->assertSession()->waitForElementRemoved('css', '[data-big-pipe-placeholder-id]', 20000);
    $this->assertSession()->elementTextContains('css', '#placeholder-preview-twig-container', $display_name);
    
    $this->assertSession()->elementTextContains('xpath', '//td', $new_label);

    // Delete the added entity using the operations link.     $this->assertSession()->linkByHrefExists('admin/content/block/' . $block->id() . '/delete');
    $this->clickLink('Delete');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->titleEquals("Are you sure you want to delete the content block $new_label? | Drupal");
    $this->submitForm([], 'Delete');

    // Verify that the text of the label and machine name does not appear in     // the list (though it may appear elsewhere on the page).     $this->assertSession()->elementTextNotContains('xpath', '//td', $new_label);

    // Confirm that the empty text is displayed.     $this->assertSession()->pageTextContains('There are no content blocks yet.');

    $block_content = BlockContent::create([
      'info' => 'Non-reusable block',
      'type' => 'basic',
      'reusable' => FALSE,
    ]);
    $block_content->save();

    
$assert_session->linkExists('Add section');
    $this->clickLink('Add section');
    $this->assertNotEmpty($assert_session->waitForElementVisible('named', ['link', 'Two column']));

    $this->clickLink('Two column');
    $assert_session->waitForElementVisible('named', ['button', 'Add section']);
    $page->pressButton('Add section');
    $assert_session->assertWaitOnAjaxRequest();

    $assert_session->assertNoElementAfterWait('css', '.layout__region--second .block-system-powered-by-block');
    $assert_session->elementTextNotContains('css', '.layout__region--second', 'Powered by Drupal');

    // Drag the block to a region in different section.     $this->sortableTo('.block-system-powered-by-block', '.layout__region--content', '.layout__region--second');
    $assert_session->assertWaitOnAjaxRequest();

    // Ensure the drag succeeded.     $assert_session->elementExists('css', '.layout__region--second .block-system-powered-by-block');
    $assert_session->elementTextContains('css', '.layout__region--second', 'Powered by Drupal');

    $this->assertPageNotReloaded();

    
/** * Asserts that the specified comment does not have a link to a parent. * * @param int $cid * The comment ID to check. * * @internal */
  protected function assertNoParentLink(int $cid): void {
    $pattern = "//article[@id='comment-$cid']";
    // A parent link is always accompanied by the text "In reply to".     $this->assertSession()->elementTextNotContains('xpath', $pattern, 'In reply to');
  }

}
$assert_session = $this->assertSession();
    $compatible_table_locator = '[data-drupal-selector="edit-projects"]';
    $incompatible_table_locator = '[data-drupal-selector="edit-not-compatible"]';

    $this->refreshUpdateStatus(['drupal' => $core_fixture, 'aaa_update_test' => $a_fixture, 'bbb_update_test' => $b_fixture]);
    $this->drupalGet('admin/reports/updates/update');

    if ($compatible) {
      // Verify the number of rows in the table.       $assert_session->elementsCount('css', "$compatible_table_locator tbody tr", count($compatible));
      // We never want to see a compatibility range in the compatible table.       $assert_session->elementTextNotContains('css', $compatible_table_locator, 'Requires Drupal core');
      foreach ($compatible as $module => $version) {
        $compatible_row = "$compatible_table_locator tbody tr:contains('$module Update test')";
        // First <td> is the checkbox, so start with td #2.         $assert_session->elementTextContains('css', "$compatible_row td:nth-of-type(2)", "$module Update test");
        // Both contrib modules use 8.x-1.0 as the currently installed version.         $assert_session->elementTextContains('css', "$compatible_row td:nth-of-type(3)", '8.x-1.0');
        $assert_session->elementTextContains('css', "$compatible_row td:nth-of-type(4)", $version);
      }
    }
    else {
      // Verify there is no compatible updates table.
$entity->setNewRevision();
    $entity->save();

    $entity->setNewRevision();
    $entity->save();

    $this->drupalGet($entity->toUrl('version-history'));
    $this->assertSession()->elementsCount('css', 'table tbody tr', 3);
    // Current revision text is found on the latest revision row.     $this->assertSession()->elementTextContains('css', 'table tbody tr:nth-child(1)', 'Current revision');
    $this->assertSession()->elementTextNotContains('css', 'table tbody tr:nth-child(2)', 'Current revision');
    $this->assertSession()->elementTextNotContains('css', 'table tbody tr:nth-child(3)', 'Current revision');
    // Current revision row has 'revision-current' class.     $this->assertSession()->elementAttributeContains('css', 'table tbody tr:nth-child(1)', 'class', 'revision-current');
  }

  /** * Test description with entity implementing revision log. * * @covers ::getRevisionDescription */
  public function testDescriptionRevLog(): void {
    
        // release but because '8.x-3.0' is not in a supported branch it will         // not be in the available updates.         $this->assertSession()->responseNotContains('8.x-3.0');
        // Set a CSS selector in order for assertions to target the 'Modules'         // table and not Drupal core updates.         $this->updateTableLocator = 'table.update:nth-of-type(2)';
        switch ($version) {
          case '1.1':
            // Both stable and unstable releases are available.             // A stable release is the latest.             if ($extra_version == '') {
              $assert_session->elementTextNotContains('css', $this->updateTableLocator, 'Up to date');
              $assert_session->elementTextContains('css', $this->updateTableLocator, 'Update available');
              $this->assertVersionUpdateLinks('Recommended version', $full_version);
              $assert_session->elementTextNotContains('css', $this->updateTableLocator, 'Latest version:');
              $assert_session->elementContains('css', $this->updateTableLocator, 'warning.svg');
            }
            // Only unstable releases are available.             // An unstable release is the latest.             else {
              $assert_session->elementTextContains('css', $this->updateTableLocator, 'Up to date');
              $assert_session->elementTextNotContains('css', $this->updateTableLocator, 'Update available');
              $assert_session->elementTextNotContains('css', $this->updateTableLocator, 'Recommended version:');
              
$this->assertTrue($checkboxes[3]->hasAttribute('disabled'));
    // Select the items.     $this->pressInsertSelected('Added 2 media items.');
    // Assert the open button is disabled.     $open_button = $this->assertElementExistsAfterWait('css', '.js-media-library-open-button[name^="field_twin_media"]');
    $this->assertTrue($open_button->hasAttribute('data-disabled-focus'));
    $this->assertTrue($open_button->hasAttribute('disabled'));
    $this->assertJsCondition('jQuery("#field_twin_media-media-library-wrapper .js-media-library-open-button").is(":disabled")');

    // Ensure that the selection completed successfully.     $assert_session->pageTextNotContains('Add or select media');
    $assert_session->elementTextNotContains('css', '#field_twin_media-media-library-wrapper', 'Dog');
    $assert_session->elementTextContains('css', '#field_twin_media-media-library-wrapper', 'Cat');
    $assert_session->elementTextContains('css', '#field_twin_media-media-library-wrapper', 'Turtle');
    $assert_session->elementTextNotContains('css', '#field_twin_media-media-library-wrapper', 'Snake');

    // Remove "Cat" (happens to be the first remove button on the page).     $button = $assert_session->buttonExists('Remove', $wrapper);
    $this->assertSame('Remove Cat', $button->getAttribute('aria-label'));
    $button->press();
    $this->waitForText('Cat has been removed.');
    // Assert the focus is set to the wrapper of the other selected item.     $this->assertJsCondition('jQuery("#field_twin_media-media-library-wrapper [data-media-library-item-delta]").is(":focus")');
    

  protected function assertSecurityUpdates($project_path_part, array $expected_security_releases$expected_update_message_type$update_element_css_locator) {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();
    $this->standardTests();
    $assert_session->elementTextNotContains('css', $update_element_css_locator, 'Not supported');
    $all_security_release_urls = array_map(function D$link) {
      return $link->getAttribute('href');
    }$page->findAll('css', "$update_element_css_locator .version-security a[href$='-release']"));
    if ($expected_security_releases) {
      $expected_release_urls = [];
      if ($expected_update_message_type === static::SECURITY_UPDATE_REQUIRED) {
        $assert_session->elementTextNotContains('css', $update_element_css_locator, 'Update available');
        $assert_session->elementTextContains('css', $update_element_css_locator, 'Security update required!');
        // Verify that the error icon is found.         $assert_session->responseContains('error.svg');
      }
      
Home | Imprint | This part of the site doesn't use cookies.