press example

$this->assertNotNull($link1_modal, 'Link was used to open a dialog ( non-modal )');
    $this->assertSession()->responseContains($dialog_contents);

    $dialog_title = $link1_dialog_div->find('css', "span.ui-dialog-title:contains('AJAX Dialog & contents')");
    $this->assertNotNull($dialog_title);
    $dialog_title_amp = $link1_dialog_div->find('css', "span.ui-dialog-title:contains('AJAX Dialog & contents')");
    $this->assertNull($dialog_title_amp);

    // Close open dialog, return to the dialog links page.     $close_button = $link1_dialog_div->findButton('Close');
    $this->assertNotNull($close_button);
    $close_button->press();

    // Tests a modal with a dialog-option.     // Link 2 is similar to Link 1, except it submits additional width     // information which must be echoed in the resulting DOM update.     $this->getSession()->getPage()->clickLink('Link 2 (modal)');
    $dialog = $this->assertSession()->waitForElementVisible('css', 'div.ui-dialog');
    $this->assertNotNull($dialog, 'Link was used to open a dialog ( non-modal, with options )');
    $style = $dialog->getAttribute('style');
    $this->assertStringContainsString('width: 400px;', $stylenew FormattableMarkup('Modal respected the dialog-options width parameter. Style = style', ['%style' => $style]));

    // Reset: Return to the dialog links page.
->save();

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('admin/structure/views/view/user_admin_people');
    $assert_session->pageTextContains('This is text added to the display tabs at the top');
    $assert_session->pageTextContains('This is text added to the display edit form');
    $page->clickLink('User: Name (Username)');
    $assert_session->waitForElementVisible('css', '.views-ui-dialog');
    $page->fillField('Label', 'New Title');
    $page->find('css', '.ui-dialog-buttonset button:contains("Apply")')->press();
    $assert_session->waitForElementRemoved('css', '.views-ui-dialog');
    $assert_session->pageTextContains('This is text added to the display tabs at the top');
    $assert_session->pageTextContains('This is text added to the display edit form');
  }

}
$this->createMediaTypeFields($fields$media_type_id);

    // Hide the name field widget to test default name generation.     $this->hideMediaTypeFieldWidget('name', $media_type_id);

    $this->drupalGet("admin/structure/media/manage/$media_type_id");
    // Only accept Vimeo videos.     $page->checkField("source_configuration[providers][Vimeo]");
    $assert_session->selectExists('field_map[width]')->setValue('field_string_width');
    $assert_session->selectExists('field_map[height]')->setValue('field_string_height');
    $assert_session->selectExists('field_map[author_name]')->setValue('field_string_author_name');
    $assert_session->buttonExists('Save')->press();

    // Configure the iframe to be narrower than the actual video, so we can     // verify that the video scales correctly.     $display = \Drupal::service('entity_display.repository')->getViewDisplay('media', $media_type_id);
    $this->assertFalse($display->isNew());
    $component = $display->getComponent('field_media_oembed_video');
    $this->assertIsArray($component);
    $component['settings']['max_width'] = 240;
    $display->setComponent('field_media_oembed_video', $component);
    $this->assertSame(SAVED_UPDATED, $display->save());

    

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

    $this->drupalGet('tour-test-1');

    $assert_session->assertNoElementAfterWait('css', '.tip-tour-test-1');

    // Open the tour.     $page->find('css', '#toolbar-tab-tour button')->press();

    // Confirm the tour can be cancelled.     $tip_to_close = $assert_session->waitForElementVisible('css', '.shepherd-enabled.tip-tour-test-1');
    $this->assertNotNull($tip_to_close);
    $tip_text = $tip_to_close->getText();
    $this->assertStringContainsString('always the best dressed', $tip_text);
    $this->assertStringContainsString('1 of 3', $tip_text);
    $this->assertStringNotContainsString('End tour', $tip_text);

    // Cancel the tour.     $tip_to_close->find('css', '.shepherd-cancel-icon')->press();
    
$link_titles[] = $link->getText();
    }
    $expected_link_titles = ['Show Type Three media (selected)', 'Show Type One media', 'Show Type Two media', 'Show Type Four media'];
    $this->assertSame($link_titles$expected_link_titles);
    $this->drupalGet('admin/structure/types/manage/basic_page/form-display');

    // Ensure that the widget settings form is not displayed when only     // one media type is allowed.     $assert_session->pageTextContains('Single media type');
    $assert_session->buttonNotExists('field_single_media_type_settings_edit');

    $assert_session->buttonExists('field_twin_media_settings_edit')->press();
    $this->assertElementExistsAfterWait('css', '#field-twin-media .tabledrag-toggle-weight')->press();
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_one][weight]')->selectOption(0);
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_three][weight]')->selectOption(1);
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_four][weight]')->selectOption(2);
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_two][weight]')->selectOption(3);
    $assert_session->buttonExists('Save')->press();

    $this->drupalGet('node/add/basic_page');
    $this->openMediaLibraryForField('field_twin_media');
    $link_titles = array_map(function D$link) {
      return $link->getText();
    },
$page = $session->getPage();
    $assert_session = $this->assertSession();

    $field_new_storage_type = $page->findField('new_storage_type');
    $field_new_storage_type->setValue($field_type);

    $field_label = $page->findField('label');
    $this->assertTrue($field_label->isVisible());
    $field_label->setValue($label);
    $machine_name = $assert_session->waitForElementVisible('css', '[name="label"] + * .machine-name-value');
    $this->assertNotEmpty($machine_name);
    $page->findButton('Edit')->press();

    $field_field_name = $page->findField('field_name');
    $this->assertTrue($field_field_name->isVisible());
    $field_field_name->setValue($field_name);

    $page->findButton('Save and continue')->click();

    $assert_session->pageTextContains("These settings apply to the $label field everywhere it is used.");
    $breadcrumb_link = $page->findLink($label);

    // Test breadcrumb.


  /** * Press the toolbar Edit button provided by the contextual module. */
  protected function pressToolbarEditButton() {
    $this->assertSession()->waitForElement('css', '[data-contextual-id] .contextual-links a');
    $edit_button = $this->getSession()
      ->getPage()
      ->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR);
    $edit_button->mouseOver();
    $edit_button->press();
  }

  /** * Assert that edit mode has been properly disabled. */
  protected function assertEditModeDisabled() {
    $web_assert = $this->assertSession();
    $page = $this->getSession()->getPage();
    $page->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)->mouseOver();
    $this->assertTrue($page->waitFor(10, function D$page) {
      return !$page->find('css', '.contextual .trigger:not(.visually-hidden)');
    }));


  /** * Tests action plugins with AJAX save their configuration. */
  public function testActionConfigurationWithAjax() {
    $url = Url::fromRoute('action.admin_add', ['action_id' => 'action_form_ajax_test']);
    $this->drupalGet($url);
    $page = $this->getSession()->getPage();

    $id = 'test_plugin';
    $this->assertSession()->waitForElementVisible('named', ['button', 'Edit'])->press();
    $this->assertSession()->waitForElementVisible('css', '[name="id"]')->setValue($id);

    $page->find('css', '[name="having_a_party"]')
      ->check();
    $this->assertSession()->waitForElementVisible('css', '[name="party_time"]');

    $party_time = 'Evening';
    $page->find('css', '[name="party_time"]')
      ->setValue($party_time);

    $page->find('css', '[value="Save"]')
      

  public function testRevisionContextualLinks() {
    // Confirm that the "Edit" and "Delete" contextual links appear for the     // default revision.     $this->drupalGet('node/' . $this->nodes[0]->id());
    $page = $this->getSession()->getPage();
    $page->waitFor(10, function D) use ($page) {
      return $page->find('css', "main .contextual");
    });

    $this->toggleContextualTriggerVisibility('main');
    $page->find('css', 'main .contextual button')->press();
    $links = $page->findAll('css', "main .contextual-links li a");

    $this->assertEquals('Edit', $links[0]->getText());
    $this->assertEquals('Delete', $links[1]->getText());

    // Confirm that "Edit" and "Delete" contextual links don't appear for     // non-default revision.     $this->drupalGet("node/" . $this->nodes[0]->id() . "/revisions/" . $this->nodes[1]->getRevisionId() . "/view");
    $this->assertSession()->pageTextContains($this->nodes[1]->getTitle());
    $page->waitFor(10, function D) use ($page) {
      return $page->find('css', "main .contextual");
    });
    $this->drupalGet($manage_form);
    $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"]');
    
// Check to make sure that page was not reloaded.     $this->assertSession()->pageTextContains($current_page_string);

    // Test clicking contextual link with toolbar.     $this->container->get('module_installer')->install(['toolbar']);
    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID)['access toolbar']);
    $this->drupalGet('user');
    $this->assertSession()->assertWaitOnAjaxRequest();

    // Click "Edit" in toolbar to show contextual links.     $this->getSession()->getPage()->find('css', '.contextual-toolbar-tab button')->press();
    $this->clickContextualLink('#block-branding', 'Test Link', FALSE);
    $this->assertSession()->pageTextContains('Everything is contextual!');
  }

  /** * Tests the contextual links destination. */
  public function testContextualLinksDestination() {
    $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID)[
      'access contextual links',
      'administer blocks',
    ]);
// When no "main content" block is placed, we find a contextual link     // placeholder for editing just the view.     $this->drupalGet('test-display');
    $page = $this->getSession()->getPage();
    $this->assertSession()->assertWaitOnAjaxRequest();

    $selector = '.views-element-container';
    $this->toggleContextualTriggerVisibility($selector);

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

    $contextual_container_id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
    $contextual_container = $page->find('css', '[data-contextual-id="' . $contextual_container_id . '"]');
    $this->assertNotEmpty($contextual_container);

    $edit_link = $contextual_container->findLink('Edit view');
    $this->assertNotEmpty($edit_link);

    // When a "main content" is placed, we still find a contextual link     // placeholder for editing just the view (not the main content block).     // @see system_block_view_system_main_block_alter()
$this->assertNotEmpty($preview);

    // Tests linking Drupal media.     $drupalmedia->click();
    $this->assertTrue($drupalmedia->hasClass('ck-widget_selected'));
    $this->assertEditorButtonEnabled('Link');
    // Assert structure of image toolbar balloon.     $this->assertVisibleBalloon('.ck-toolbar[aria-label="Drupal Media toolbar"]');
    $link_media_button = $this->getBalloonButton('Link media');
    // Click the "Link media" button.     $this->assertSame('false', $link_media_button->getAttribute('aria-pressed'));
    $link_media_button->press();
    // Assert structure of link form balloon.     $balloon = $this->assertVisibleBalloon('.ck-link-form');
    $url_input = $balloon->find('css', '.ck-labeled-field-view__input-wrapper .ck-input-text');
    // Fill in link form balloon's <input> and hit "Save".     $url_input->setValue('http://linking-embedded-media.com');
    $balloon->pressButton('Save');

    // Assert the "editingDowncast" HTML after making changes. Assert the link     // exists, then assert the link exists. Then assert the expected DOM     // structure in detail.     $assert_session->elementExists('css', '.ck-content a[href="http://linking-embedded-media.com"]');
    
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) {
      $this->toggleContextualTriggerVisibility($selector);
    }
  }

  
$this->assertSession()->pageContainsNoDuplicateId();

    // Submit the "add more" button of each form twice. After each corresponding     // page update, ensure the same as above.
    for ($i = 0; $i < 2; $i++) {
      $forms = $page->findAll('xpath', $form_xpath);
      foreach ($forms as $offset => $form) {
        $button = $form->findButton('Add another item');
        $this->assertNotNull($button, 'Add Another Item button exists');
        $button->press();

        // Wait for field to be added with ajax.         $this->assertNotEmpty($page->waitFor(10, function D) use ($form$i) {
          return $form->findField('field_ajax_test[' . ($i + 1) . '][value]');
        }));

        // After AJAX request and response verify the correct number of text         // fields (including title), as well as the "Add another item" button.         $this->assertCount($i + 3, $form->findAll('css', 'input[type="text"]'), 'Found the correct number of field items after an AJAX submission.');
        $this->assertNotEmpty($form->findButton('Add another item'), 'Found the "add more" button after an AJAX submission.');
        $this->assertSession()->pageContainsNoDuplicateId();
      }
Home | Imprint | This part of the site doesn't use cookies.