You are here

protected function ThunderJavascriptTestBase::clickDropButton in Thunder 8.3

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

Click a button within a dropdown button field.

Parameters

string $fieldName: The [name] attribute of the button to be clicked.

bool $toggle: Whether the dropdown button should be expanded before clicking.

1 call to ThunderJavascriptTestBase::clickDropButton()
LiveblogTest::testWithPusher in tests/src/FunctionalJavascript/Integration/LiveblogTest.php
Testing of module integration.

File

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

Class

ThunderJavascriptTestBase
Base class for Thunder Javascript functional tests.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

protected function clickDropButton($fieldName, $toggle = TRUE) {
  $page = $this
    ->getSession()
    ->getPage();
  if ($toggle) {
    $toggleButtonXpath = '//ul[.//*[@name="' . $fieldName . '"]]/li[contains(@class,"dropbutton-toggle")]/button';
    $toggleButton = $page
      ->find('xpath', $toggleButtonXpath);
    $toggleButton
      ->click();
    $this
      ->assertSession()
      ->assertWaitOnAjaxRequest();
  }
  $this
    ->scrollElementInView('[name="' . $fieldName . '"]');
  $page
    ->pressButton($fieldName);
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
}