You are here

public function MediaBrowserContext::open in Lightning Media 8

Same name and namespace in other branches
  1. 8.2 tests/contexts/MediaBrowserContext.behat.inc \Acquia\LightningExtension\Context\MediaBrowserContext::open()
  2. 8.3 tests/contexts/MediaBrowserContext.behat.inc \Acquia\LightningExtension\Context\MediaBrowserContext::open()

Opens the media browser, obviously.

@When I open the media browser

Parameters

string $button: (optional) The embed button ID.

File

tests/contexts/MediaBrowserContext.behat.inc, line 38

Class

MediaBrowserContext
Contains step definitions for interacting with Lightning's media browser.

Namespace

Acquia\LightningExtension\Context

Code

public function open($button = 'media_browser') {
  $this
    ->getContext(CkEditorContext::class)
    ->execute('editdrupalentity', NULL, [
    'id' => $button,
  ]);
  $frame = $this
    ->awaitElement("iframe[name='entity_browser_iframe_{$button}']", 30)
    ->getAttribute('name');
  $this
    ->getSession()
    ->switchToIFrame($frame);

  // For whatever reason, the iFrame switch does not appear to take effect
  // immediately under certain circumstances. I don't know what is going on
  // here, but this needs to be revisited later. 2 seconds appears to be too
  // soon, but 3 works consistently for me in my local environment.
  sleep(3);
}