You are here

protected function WysiwygSubContext::getWysiwygToolbar in Panopoly 8.2

Same name and namespace in other branches
  1. 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test_wysiwyg.behat.inc \WysiwygSubContext::getWysiwygToolbar()

Get a Mink Element representing the WYSIWYG toolbar.

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

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

2 calls to WysiwygSubContext::getWysiwygToolbar()
WysiwygSubContext::iClickTheButtonInTheWysiwygEditor in modules/panopoly/panopoly_test/behat/steps/panopoly_test_wysiwyg.behat.inc
Clicks a button in a WYSIWYG editor.
WysiwygSubContext::iExpandTheToolbarInTheWysiwygEditor in modules/panopoly/panopoly_test/behat/steps/panopoly_test_wysiwyg.behat.inc
Expands the toolbar in the WYSIWYG editor.

File

modules/panopoly/panopoly_test/behat/steps/panopoly_test_wysiwyg.behat.inc, line 86
Provide Behat step-definitions for WYSIWYG editor.

Class

WysiwygSubContext
Behat subcontext for testing WYSIWYG.

Code

protected function getWysiwygToolbar($instanceId, $editorType) {
  $driver = $this
    ->getSession()
    ->getDriver();
  $toolbarElement = NULL;
  switch ($editorType) {
    case 'ckeditor':
      $toolbarElement = $driver
        ->find("//div[@id='cke_{$instanceId}']//span[contains(@class, 'cke_top')]");
      $toolbarElement = !empty($toolbarElement) ? $toolbarElement[0] : NULL;
      break;
    case 'tinymce':
      $toolbarElement = $driver
        ->find("//div[@id='{$instanceId}_toolbargroup']");
      $toolbarElement = !empty($toolbarElement) ? $toolbarElement[0] : NULL;
      break;
    case 'markitup':
      $elementId = 'markItUp' . ucfirst($instanceId);
      $toolbarElement = $driver
        ->find("//div[@id='{$elementId}']//div[@class='markItUpHeader']");
      $toolbarElement = !empty($toolbarElement) ? $toolbarElement[0] : NULL;
      break;
  }
  if (!$toolbarElement) {
    throw new \Exception(sprintf('Toolbar for editor "%s" was not found on the page %s', $instanceId, $this
      ->getSession()
      ->getCurrentUrl()));
  }
  return $toolbarElement;
}