You are here

public function MediaBrowserContext::completeSelection in Lightning Media 8

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

Completes the media browser selection.

@When I complete the media browser selection

File

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

Class

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

Namespace

Acquia\LightningExtension\Context

Code

public function completeSelection() {
  $session = $this
    ->getSession();

  // The iframe is destroyed after submitting it, so we need to switch back
  // into the window context in order for the session to stay sane.
  $session
    ->switchToWindow();
  $frame = 'window.frames.entity_browser_iframe_media_browser';
  $session
    ->executeScript("{$frame}.document.forms[0].elements.op.click()");
  $this
    ->awaitExpression("!{$frame}");
  $this
    ->awaitAjax();
  $this
    ->awaitElement('form.entity-embed-dialog');
  $session
    ->executeScript('document.querySelector("form.entity-embed-dialog").elements.op[1].click()');
  $this
    ->awaitAjax();
}