function EditModeTest::getTabbableElementsCount

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

Gets the number of elements that are tabbable.

Return value

int The number of tabbable elements.

1 call to EditModeTest::getTabbableElementsCount()
EditModeTest::testEditModeEnableDisable in core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php
Tests enabling and disabling edit mode.

File

core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php, line 136

Class

EditModeTest
Tests edit mode.

Namespace

Drupal\Tests\contextual\FunctionalJavascript

Code

protected function getTabbableElementsCount() {
    // Mark all tabbable elements.
    $this->getSession()
        ->executeScript("jQuery(window.tabbable.tabbable(document.body)).attr('data-marked', '');");
    // Count all marked elements.
    $count = count($this->getSession()
        ->getPage()
        ->findAll('css', "[data-marked]"));
    // Remove set attributes.
    $this->getSession()
        ->executeScript("jQuery('[data-marked]').removeAttr('data-marked');");
    return $count;
}

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