function TableDragTest::markRowHandleForDragging

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::markRowHandleForDragging()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::markRowHandleForDragging()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::markRowHandleForDragging()

Marks a row handle for dragging.

The handle is marked by adding a css class that is removed by an helper js library once the dragging is over.

Parameters

\Behat\Mink\Element\NodeElement $handle: The draggable row handle element.

Throws

\Exception Thrown when the class is not added successfully to the handle.

1 call to TableDragTest::markRowHandleForDragging()
TableDragTest::moveRowWithKeyboard in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Moves a row through the keyboard.

File

core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php, line 630

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

protected function markRowHandleForDragging(NodeElement $handle) {
    $class = self::DRAGGING_CSS_CLASS;
    $script = <<<JS
document.evaluate("{<span class="php-variable">$handle</span>-&gt;<span class="php-function-or-constant function member-of-variable">getXpath</span>()}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
  .singleNodeValue.classList.add('{<span class="php-variable">$class</span>}');
JS;
    $this->getSession()
        ->executeScript($script);
    $has_class = $this->getSession()
        ->getPage()
        ->waitFor(1, function () use ($handle, $class) {
        return $handle->hasClass($class);
    });
    if (!$has_class) {
        throw new \Exception(sprintf('Dragging css class was not added on handle "%s".', $handle->getXpath()));
    }
}

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