function OffCanvasTestTrait::waitForOffCanvasArea

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Traits/OffCanvasTestTrait.php \Drupal\Tests\system\Traits\OffCanvasTestTrait::waitForOffCanvasArea()
  2. 10 core/modules/system/tests/src/Traits/OffCanvasTestTrait.php \Drupal\Tests\system\Traits\OffCanvasTestTrait::waitForOffCanvasArea()

Waits for the off-canvas area to appear, resized and visible.

File

core/modules/system/tests/src/Traits/OffCanvasTestTrait.php, line 17

Class

OffCanvasTestTrait
Provides helper methods for interacting with the off-canvas area.

Namespace

Drupal\Tests\system\Traits

Code

protected function waitForOffCanvasArea() : void {
  // The data-resize-done attribute is added by the off_canvas_test module's
  // wrapper around Drupal.offCanvas.resetSize.
  $this->assertNotEmpty($this->assertSession()
    ->waitForElementVisible('css', '[data-resize-done="true"]'));
  // Remove the data-resize-done attribute so in scenarios where off-canvas
  // opens yet another off-canvas, waitForOffCanvasArea() is looking for the
  // attribute on a new dialog, not an existing one.
  $this->getSession()
    ->executeScript('document.querySelector("[data-resize-done]").removeAttribute("data-resize-done")');
}

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