function UiHelperTrait::click

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::click()
  2. 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::click()
  3. 8.9.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::click()

Clicks the element with the given CSS selector.

Parameters

string $css_selector: The CSS selector identifying the element to click.

3 calls to UiHelperTrait::click()
ElementsTableSelectTest::testAjax in core/modules/system/tests/src/FunctionalJavascript/Form/ElementsTableSelectTest.php
Tests the presence of ajax functionality for all options.
MediaEmbedFilterConfigurationUiTest::testValidationWhenAdding in core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiTest.php
@covers ::media_form_filter_format_add_form_alter[[api-linebreak]] @covers ::media_filter_format_edit_form_validate[[api-linebreak]] @dataProvider providerTestValidations
MediaEmbedFilterConfigurationUiTest::testValidationWhenEditing in core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiTest.php
@covers ::media_form_filter_format_edit_form_alter[[api-linebreak]] @covers ::media_filter_format_edit_form_validate[[api-linebreak]] @dataProvider providerTestValidations

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 470

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function click($css_selector) {
  $starting_url = $this->getSession()
    ->getCurrentUrl();
  $this->getSession()
    ->getDriver()
    ->click($this->cssSelectToXpath($css_selector));
  // Log only for WebDriverTestBase tests because for BrowserKitDriver we log
  // with ::getResponseLogHandler.
  if ($this->htmlOutputEnabled && !$this->isTestUsingGuzzleClient()) {
    $out = $this->getSession()
      ->getPage()
      ->getContent();
    $html_output = 'Clicked element with CSS selector: ' . $css_selector . '<hr />Starting URL: ' . $starting_url . '<hr />Ending URL: ' . $this->getSession()
      ->getCurrentUrl();
    $html_output .= '<hr />' . $out;
    $html_output .= $this->getHtmlOutputHeaders();
    $this->htmlOutput($html_output);
  }
}

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