You are here

protected function EditModeTest::getTabbableElementsCount in Drupal 8

Same name and namespace in other branches
  1. 9 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()

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 132

Class

EditModeTest
Tests edit mode.

Namespace

Drupal\Tests\contextual\FunctionalJavascript

Code

protected function getTabbableElementsCount() {

  // Mark all tabbable elements.
  $this
    ->getSession()
    ->executeScript("jQuery(':tabbable').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;
}