protected function TableDragTest::markRowHandleForDragging in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::markRowHandleForDragging()
- 9 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 628
Class
- TableDragTest
- Tests draggable table.
Namespace
Drupal\FunctionalJavascriptTests\TableDragCode
protected function markRowHandleForDragging(NodeElement $handle) {
$class = self::DRAGGING_CSS_CLASS;
$script = <<<JS
document.evaluate("{<span class="php-variable">$handle</span>
-><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()));
}
}