Skip to content

Commit

Permalink
OP-543: Behat fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Sep 13, 2024
1 parent d2f4438 commit c31c6c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
20 changes: 18 additions & 2 deletions tests/Behat/Page/Admin/Block/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,24 @@ public function addTextareaContentElementWithContent(string $content): void
{
Assert::isInstanceOf($this->getDriver(), ChromeDriver::class);

$textarea = $this->getElement('content_elements_textarea');
$textarea->setValue($content);
$iframe = $this->getDocument()->find('css', '.cke_wysiwyg_frame');
if (null === $iframe) {
$textarea = $this->getElement('content_elements_textarea');
$textarea->setValue($content);

return;
}

$this->getDriver()->switchToIFrame($iframe->getAttribute('name'));

$body = $this->getDocument()->find('css', 'body');
if (null === $body) {
throw new \Exception('CKEditor body not found');
}

$body->setValue($content);

$this->getDriver()->switchToIFrame();
}

public function addSingleMediaContentElementWithName(string $name): void
Expand Down
7 changes: 5 additions & 2 deletions tests/Behat/Page/Admin/Page/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ public function addTextareaContentElementWithContent(string $content): void

$iframe = $this->getDocument()->find('css', '.cke_wysiwyg_frame');
if (null === $iframe) {
throw new \Exception('CKEditor iframe not found');
$textarea = $this->getElement('content_elements_textarea');
$textarea->setValue($content);

return;
}

$this->getDriver()->switchToIFrame($iframe->getAttribute('name'));
Expand All @@ -125,7 +128,7 @@ public function addTextareaContentElementWithContent(string $content): void

$body->setValue($content);

$this->getDriver()->switchToIFrame(null);
$this->getDriver()->switchToIFrame();
}

public function addSingleMediaContentElementWithName(string $name): void
Expand Down

0 comments on commit c31c6c5

Please sign in to comment.