public function EntityBrowserContext::submit in Lightning Media 8.2
Same name and namespace in other branches
- 8 tests/contexts/EntityBrowserContext.behat.inc \Acquia\LightningExtension\Context\EntityBrowserContext::submit()
- 8.3 tests/contexts/EntityBrowserContext.behat.inc \Acquia\LightningExtension\Context\EntityBrowserContext::submit()
Submits the entity browser.
@When I submit the entity browser
File
- tests/
contexts/ EntityBrowserContext.behat.inc, line 140
Class
- EntityBrowserContext
- Contains step definitions for interacting with entity browser instances.
Namespace
Acquia\LightningExtension\ContextCode
public function submit() {
$session = $this
->getSession();
// @TODO: Make this smarter, because we can't be sure that #edit-submit
// exists at all, or that it's the correct submit button.
$button = $this
->assertSession()
->elementExists('css', '#edit-submit')
->getXpath();
$frame = $session
->evaluateScript('window.name') ?: $session
->evaluateScript('window.active_iframe.name');
assert(!empty($frame));
// Switch out of the iFrame, because it will be destroyed as soon as we
// press the button.
$session
->switchToIFrame();
$js = <<<END
document.evaluate('{<span class="php-variable">$button</span>}', window.{<span class="php-variable">$frame</span>}.document, null).iterateNext().click();
END;
$session
->executeScript($js);
$this
->awaitAjax();
}