You are here

public function WysiwygSubContext::iExpandTheToolbarInTheWysiwygEditor 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::iExpandTheToolbarInTheWysiwygEditor()

Expands the toolbar in the WYSIWYG editor.

@When I expand the toolbar in the :instanceId WYSIWYG editor

File

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

Class

WysiwygSubContext
Behat subcontext for testing WYSIWYG.

Code

public function iExpandTheToolbarInTheWysiwygEditor($instanceId) {
  $editorType = $this
    ->getEditorType($instanceId);
  $toolbarElement = $this
    ->getWysiwygToolbar($instanceId, $editorType);

  // @todo This is tinyMCE specific. We should probably switch on
  // $editorType.
  $action = 'Show/hide toolbars';

  // Expand wysiwyg toolbar.
  $button = $toolbarElement
    ->find("xpath", "//a[starts-with(@title, '{$action}')]");
  if (!$button) {
    throw new \Exception(sprintf('Button "%s" was not found on the page %s', $action, $this
      ->getSession()
      ->getCurrentUrl()));
  }
  if (strpos($button
    ->getAttribute('class'), 'cke_button_on') !== FALSE) {
    $button
      ->click();
  }
}