You are here

public function ParagraphsFeaturesJavascriptTestBase::scrollElementInView in Paragraphs Features 8

Same name and namespace in other branches
  1. 2.x tests/src/FunctionalJavascript/ParagraphsFeaturesJavascriptTestBase.php \Drupal\Tests\paragraphs_features\FunctionalJavascript\ParagraphsFeaturesJavascriptTestBase::scrollElementInView()

Scroll element with defined css selector in middle of browser view.

Parameters

string $cssSelector: CSS Selector for element that should be centralized.

1 call to ParagraphsFeaturesJavascriptTestBase::scrollElementInView()
ParagraphsFeaturesSplitTextTest::testSplitTextFeature in tests/src/FunctionalJavascript/ParagraphsFeaturesSplitTextTest.php
Test split text feature.

File

tests/src/FunctionalJavascript/ParagraphsFeaturesJavascriptTestBase.php, line 168

Class

ParagraphsFeaturesJavascriptTestBase
Base class for Javascript tests for paragraphs features module.

Namespace

Drupal\Tests\paragraphs_features\FunctionalJavascript

Code

public function scrollElementInView($cssSelector) {
  $this
    ->getSession()
    ->executeScript('
        var element = document.querySelector(\'' . addcslashes($cssSelector, '\'') . '\');
        element.scrollIntoView({block: "center"});
      ');
}