You are here

protected function FeatureContext::getWysiwygToolbar in Bear 7

Get a Mink Element representing the WYSIWYG toolbar.

Altered for CKEditor

Parameters

string $instanceId: The instanceId used by the WYSIWYG module to identify the instance.

string $editorType: Identifies the underlying editor (for example, "tinymce").

Return value

\Behat\Mink\Element\NodeElement The toolbar DOM Node.

Throws

Exeception Throws an exception if the toolbar can't be found.

2 calls to FeatureContext::getWysiwygToolbar()
FeatureContext::iClickTheButtonInTheWysiwygEditor in tests/features/bootstrap/FeatureContext.php
@When /^I click the "([^"]*)" button in the "([^"]*)" WYSIWYG editor$/
FeatureContext::iExpandTheToolbarInTheWysiwygEditor in tests/features/bootstrap/FeatureContext.php
@When /^I expand the toolbar in the "([^"]*)" WYSIWYG editor$/

File

tests/features/bootstrap/FeatureContext.php, line 246

Class

FeatureContext
Defines application features from the specific context.

Code

protected function getWysiwygToolbar($instanceId) {
  $driver = $this
    ->getSession()
    ->getPage();

  // TODO: This is tinyMCE specific. We should probably do a switch statement
  // based on $editorType.
  $wysiwyg = $driver
    ->find("xpath", "//div[@id='cke_{$instanceId}']");
  if ($wysiwyg === NULL) {
    throw new \Exception(sprintf('The wysiwyg "%s" was not found on the page', $instanceId));
  }
  $toolbarElement = $wysiwyg
    ->find("xpath", "//span[@class='cke_toolbar']");
  if ($toolbarElement === NULL) {
    throw new \Exception(sprintf('Toolbar for editor "%s" was not found on the page %s', $instanceId, $this
      ->getSession()
      ->getCurrentUrl()));
  }
  return $toolbarElement;
}