You are here

public function ThunderJavascriptTestBase::clickAjaxButtonCssSelector in Thunder 8.2

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderJavascriptTestBase::clickAjaxButtonCssSelector()
  2. 8.3 tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderJavascriptTestBase::clickAjaxButtonCssSelector()
  3. 8.4 tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderJavascriptTestBase::clickAjaxButtonCssSelector()
  4. 6.2.x tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderJavascriptTestBase::clickAjaxButtonCssSelector()
  5. 6.0.x tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderJavascriptTestBase::clickAjaxButtonCssSelector()
  6. 6.1.x tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderJavascriptTestBase::clickAjaxButtonCssSelector()

Click on Ajax Button based on CSS selector.

Ajax buttons handler is triggered on "mousedown" event, so it has to be triggered over JavaScript.

Parameters

string $cssSelector: CSS selector.

bool $waitAfterAction: Flag to wait for AJAX request to finish after click.

1 call to ThunderJavascriptTestBase::clickAjaxButtonCssSelector()
MediaGalleryModifyTest::testAddRemove in tests/src/FunctionalJavascript/MediaGalleryModifyTest.php
Test add/remove Images in Gallery.

File

tests/src/FunctionalJavascript/ThunderJavascriptTestBase.php, line 225

Class

ThunderJavascriptTestBase
Base class for Thunder Javascript functional tests.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function clickAjaxButtonCssSelector($cssSelector, $waitAfterAction = TRUE) {
  $this
    ->scrollElementInView($cssSelector);
  $this
    ->getSession()
    ->executeScript("jQuery('{$cssSelector}').trigger('mousedown');");
  if ($waitAfterAction) {
    $this
      ->assertSession()
      ->assertWaitOnAjaxRequest();
  }
}