function ContextualLinkClickTrait::clickContextualLink

Same name in other branches
  1. 9 core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait::clickContextualLink()
  2. 10 core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait::clickContextualLink()
  3. 11.x core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait::clickContextualLink()

Clicks a contextual link.

Parameters

string $selector: The selector for the element that contains the contextual link.

string $link_locator: The link id, title, or text.

bool $force_visible: If true then the button will be forced to visible so it can be clicked.

19 calls to ContextualLinkClickTrait::clickContextualLink()
BlockFormMessagesTest::testValidationMessage in core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFormMessagesTest.php
Tests that validation messages are shown on the block form.
ContentPreviewToggleTest::assertContextualLinks in core/modules/layout_builder/tests/src/FunctionalJavascript/ContentPreviewToggleTest.php
Checks if contextual links are working properly.
ContextualLinksTest::testContextualLinksClick in core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php
Test clicking contextual links.
FieldTest::testFieldWithCkeditor in core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
Tests that quickeditor works correctly for field with CKEditor.
InlineBlockPrivateFilesTest::replaceFileInBlock in core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php
Replaces the file in the block with another one.

... See full list

1 method overrides ContextualLinkClickTrait::clickContextualLink()
LayoutBuilderTest::clickContextualLink in core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
@todo Remove this in https://www.drupal.org/project/drupal/issues/2918718.

File

core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php, line 20

Class

ContextualLinkClickTrait
Functions for testing contextual links.

Namespace

Drupal\Tests\contextual\FunctionalJavascript

Code

protected function clickContextualLink($selector, $link_locator, $force_visible = TRUE) {
    $page = $this->getSession()
        ->getPage();
    $page->waitFor(10, function () 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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.