click example

// Test a valid workspace name.     $this->createWorkspaceThroughUi('Workspace 1', 'a0_$()+-/');

    // Test and invalid workspace name.     $this->drupalGet('/admin/config/workflow/workspaces/add');
    $this->assertSession()->statusCodeEquals(200);

    $page = $this->getSession()->getPage();
    $page->fillField('label', 'workspace2');
    $page->fillField('id', 'A!"£%^&*{}#~@?');
    $page->findButton('Save')->click();
    $page->hasContent("This value is not valid");
  }

  /** * Tests that the toolbar correctly shows the active workspace. */
  public function testWorkspaceToolbar() {
    $this->drupalLogin($this->editor1);

    $this->drupalGet('/admin/config/workflow/workspaces/add');
    $this->submitForm([
      
// 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->drupalGet('admin/modules');
    $this->assertSession()->elementExists('css', '#block-claro-help');
  }

  /** * Tests that the Claro theme can be uninstalled. */
  public function testIsUninstallable() {
    $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer themes']));

    $this->drupalGet('admin/appearance');
    $this->cssSelect('a[title="Install <strong>Test theme</strong> as default theme"]')[0]->click();
    $this->cssSelect('a[title="Uninstall Claro theme"]')[0]->click();
    $this->assertSession()->pageTextContains('The Claro theme has been uninstalled.');
  }

  /** * Tests pager attribute is present using pager_test. */
  public function testPagerAttribute(): void {
    // Insert 300 log messages.     $logger = $this->container->get('logger.factory')->get('pager_test');
    for ($i = 0; $i < 300; $i++) {
      
      for ($j = 1; $j <= $i$j++) {
        $other_row = 'row' . $j;
        $page->hasCheckedField($other_row);
      }
    }

    // Test radios (#multiple == FALSE).     $this->drupalGet('form_test/tableselect/multiple-false');
    for ($i = 1; $i <= 3; $i++) {
      $row = 'input[value="row' . $i . '"]';
      $page->hasUncheckedField($row);
      $this->click($row);
      $this->assertSession()->assertWaitOnAjaxRequest();
      $page->hasCheckedField($row);
      // Check other rows are not checked       for ($j = 1; $j <= 3; $j++) {
        if ($j == $i) {
          continue;
        }
        $other_row = 'edit-tableselect-row' . $j;
        $page->hasUncheckedField($other_row);
      }
    }
  }
$find_validation_error_messages = function D) use ($page): array {
      return $page->findAll('css', '[role=alert]:contains("The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Bold (<strong>).")');
    };

    // No validation errors when we start.     $this->assertCount(0, $find_validation_error_messages());

    // Configure Source Editing to allow editing `<strong>` to trigger     // validation error.     $assert_session->waitForText('Source editing');
    $page->find('css', '[href^="#edit-editor-settings-plugins-ckeditor5-sourceediting"]')->click();
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->waitForText('Manually editable HTML tags');
    $source_edit_tags_field = $assert_session->fieldExists('editor[settings][plugins][ckeditor5_sourceEditing][allowed_tags]');
    $source_edit_tags_field->setValue('<strong>');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertCount(1, $find_validation_error_messages());

    // Revert Source Editing it: validation messages should be gone.     $source_edit_tags_field->setValue('');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertCount(0, $find_validation_error_messages());

    

  public function testCreateViewWizard() {
    $this->drupalGet('admin/structure/views/add');
    $page = $this->getSession()->getPage();

    // Set a view name, this should be used to prepopulate a number of other     // fields when creating displays.     $label_value = 'test view';
    $search_input = $page->findField('label');
    $search_input->setValue($label_value);

    $page->findField('page[create]')->click();

    // Test if the title and path have been populated.     $this->assertEquals($label_value$page->findField('page[title]')->getValue());
    $this->assertEquals(str_replace(' ', '-', $label_value)$page->findField('page[path]')->getValue());

    // Create a menu item.     $page->findField('page[link]')->click();
    $this->assertEquals($label_value$page->findField('page[link_properties][title]')->getValue());

    // Wait for conditional field to show.     $this->assertSession()->waitForElementVisible('named', ['select', 'page[link_properties][parent]']);

    
      $this->assertEquals($test_info['expected']$machine_name_1_value->getHtml()$test_info['message']);

      // Validate the second machine name field is empty.       $this->assertEmpty($machine_name_2_value->getHtml(), 'The second machine name field should still be empty');
    }

    // Validate the machine name field is hidden.     $this->assertFalse($machine_name_1_wrapper->isVisible(), 'The ID field must not be visible');
    $this->assertFalse($machine_name_2_wrapper->isVisible(), 'The ID field must not be visible');

    // Test switching back to the manual editing mode by clicking the edit link.     $button_1->click();

    // Validate the visibility of the machine name field.     $this->assertTrue($machine_name_1_wrapper->isVisible(), 'The ID field must now be visible');

    // Validate the visibility of the second machine name field.     $this->assertFalse($machine_name_2_wrapper->isVisible(), 'The ID field must not be visible');

    // Validate if the element contains the correct value.     $this->assertEquals($test_values[1]['expected']$machine_name_1_field->getValue(), 'The ID field value must be equal to the php generated machine name');

    // Test that machine name generation still occurs after an HTML 5
protected $profile = 'testing_install_profile_dependencies';

  /** * Tests that an install profile can require modules. */
  public function testUninstallingModules() {
    $user = $this->drupalCreateUser(['administer modules']);
    $this->drupalLogin($user);
    $this->drupalGet('admin/modules/uninstall');
    $this->assertSession()->fieldDisabled('uninstall[dblog]');
    $this->getSession()->getPage()->checkField('uninstall[ban]');
    $this->click('#edit-submit');
    // Click the confirm button.     $this->click('#edit-submit');
    $this->assertSession()->responseContains('The selected modules have been uninstalled.');
    // We've uninstalled a module therefore we need to rebuild the container in     // the test runner.     $this->rebuildContainer();
    $this->assertFalse($this->container->get('module_handler')->moduleExists('ban'));
    try {
      $this->container->get('module_installer')->uninstall(['dblog']);
      $this->fail('Uninstalled dblog module.');
    }
    
$assert_session = $this->assertSession();
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
  }

  /** * Clicks a CKEditor button. * * @param string $name * The name of the button, such as `drupallink`, `source`, etc. */
  protected function pressEditorButton($name) {
    $this->getEditorButton($name)->click();
  }

  /** * Waits for a CKEditor button and returns it when available and visible. * * @param string $name * The name of the button, such as `drupallink`, `source`, etc. * * @return \Behat\Mink\Element\NodeElement|null * The page element node if found, NULL if not. */
  
// Ensure that the tab order is correct.     $tabs = $page->findAll('css', '.media-library-menu__link');
    $expected_tab_order = [
      'Show Image media (selected)',
      'Show Arrakis media',
    ];
    foreach ($tabs as $key => $tab) {
      $this->assertSame($expected_tab_order[$key]$tab->getText());
    }

    $assert_session->pageTextContains('0 of 1 item selected');
    $assert_session->elementExists('css', '.js-media-library-item')->click();
    $assert_session->pageTextContains('1 of 1 item selected');
    $assert_session->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Insert selected');
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', $media_preview_selector, 1000));
    $xpath = new \DOMXPath($this->getEditorDataAsDom());
    $drupal_media = $xpath->query('//drupal-media')[0];
    $expected_attributes = [
      'data-entity-type' => 'media',
      'data-entity-uuid' => $this->media->uuid(),
    ];
    foreach ($expected_attributes as $name => $expected) {
      $this->assertSame($expected$drupal_media->getAttribute($name));
    }
/** * Tests installing experimental themes and dependencies in the UI. */
  public function testExperimentalConfirmForm(): void {
    // Only experimental themes should be marked as such with a parenthetical.     $this->drupalGet('admin/appearance');
    $this->assertSession()->responseContains(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION));
    $this->assertSession()->responseContains(sprintf('Experimental dependency test %s', \Drupal::VERSION));

    // First, test installing a non-experimental theme with no dependencies.     // There should be no confirmation form and no experimental theme warning.     $this->cssSelect('a[title="Install <strong>Test theme</strong> theme"]')[0]->click();
    $this->assertSession()->pageTextContains('The <strong>Test theme</strong> theme has been installed.');
    $this->assertSession()->pageTextNotContains('Experimental modules are provided for testing purposes only.');

    // Next, test installing an experimental theme with no dependencies.     // There should be a confirmation form with an experimental warning, but no     // list of dependencies.     $this->drupalGet('admin/appearance');
    $this->cssSelect('a[title="Install Experimental test theme"]')[0]->click();
    $this->assertSession()->pageTextContains('Experimental themes are provided for testing purposes only. Use at your own risk.');

    // The module should not be enabled and there should be a warning and a
$page = $this->getSession()->getPage();
    $page->waitFor(10, function D) use ($page$selector) {
      return $page->find('css', "$selector .contextual-links");
    });

    if ($force_visible) {
      $this->toggleContextualTriggerVisibility($selector);
    }

    $element = $this->getSession()->getPage()->find('css', $selector);
    $element->find('css', '.contextual button')->press();
    $element->findLink($link_locator)->click();

    if ($force_visible) {
      $this->toggleContextualTriggerVisibility($selector);
    }
  }

  /** * Toggles the visibility of a contextual trigger. * * @param string $selector * The selector for the element that contains the contextual link. */


  /** * Tests the media library widget only shows published media. */
  public function testWidget() {
    $assert_session = $this->assertSession();

    // All users should only be able to see published media items.     $this->drupalLogin($this->rootUser);
    $this->drupalGet('node/add/article');
    $assert_session->elementExists('css', '.js-media-library-open-button[name^="field_media"]')->click();
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertOnlyPublishedMedia();
    $this->drupalLogin($this->userAdmin);
    $this->drupalGet('node/add/article');
    $assert_session->elementExists('css', '.js-media-library-open-button[name^="field_media"]')->click();
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertOnlyPublishedMedia();
    $this->drupalLogin($this->userViewer);
    $this->drupalGet('node/add/article');
    $assert_session->elementExists('css', '.js-media-library-open-button[name^="field_media"]')->click();
    $assert_session->assertWaitOnAjaxRequest();
    
// Ensure that a Drupal Ajax request triggers the expected events, in the     // correct order, a single time.     // - We expect the first log element to list the events exactly once,     // because the Ajax response clears it, and we expect the events to be     // triggered after the commands are executed.     // - We expect the second log element to list the events exactly three     // times, because it already contains the two from the code that was     // already executed above. This additional log element that isn't cleared     // by the response's command ensures that the events weren't triggered     // additional times before the response commands were executed.     $this->click('#test_global_events_drupal_ajax_link');
    $assert->assertWaitOnAjaxRequest();
    $assert->elementTextEquals('css', '#test_global_events_log', $expected_event_order);
    $assert->elementTextEquals('css', '#test_global_events_log2', str_repeat($expected_event_order, 3));
  }

  /** * Assert insert. * * @param string $render_type * Render type. * @param string $expected * Expected result. * @param string $script * Script for additional theming. * * @internal */

    $remote_paths = [];
    foreach ($real_paths as $path) {
      $remote_paths[] = $web_driver->uploadFileAndGetRemoteFilePath($path);
    }

    // Tests that uploading multiple remote files works with remote path.     $this->drupalGet($entity->toUrl('edit-form'));
    $multiple_field = $this->assertSession()->elementExists('xpath', '//input[@multiple]');
    $multiple_field->setValue(implode("\n", $remote_paths));
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->getSession()->getPage()->findButton('Save')->click();
    $entity = EntityTest::load($entity->id());
    $this->assertCount(3, $entity->field_file);
  }

}
Home | Imprint | This part of the site doesn't use cookies.