You are here

protected function LayoutBuilderDisableInteractionsTest::getElementVerticalPosition in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::getElementVerticalPosition()

Gets the element position.

Parameters

string $css_selector: The CSS selector of the element.

string $position_type: The position type to get, either 'top' or 'bottom'.

Return value

int The element position.

1 call to LayoutBuilderDisableInteractionsTest::getElementVerticalPosition()
LayoutBuilderDisableInteractionsTest::assertContextualLinkRetainsMouseup in core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
Makes sure contextual links respond to mouseup event.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php, line 295

Class

LayoutBuilderDisableInteractionsTest
Tests the Layout Builder disables interactions of rendered blocks.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function getElementVerticalPosition($css_selector, $position_type) {
  $this
    ->assertContains($position_type, [
    'top',
    'bottom',
  ], 'Expected position type.');
  return (int) $this
    ->getSession()
    ->evaluateScript("document.querySelector('{$css_selector}').getBoundingClientRect().{$position_type} + window.pageYOffset");
}