You are here

public function WysiwygSubContext::iExpandTheToolbarInTheWysiwygEditor in Panopoly 7

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

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

File

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

Class

WysiwygSubContext

Code

public function iExpandTheToolbarInTheWysiwygEditor($instanceId) {
  $driver = $this
    ->getSession()
    ->getDriver();
  $instance = $this
    ->getWysiwygInstance($instanceId);
  $editorType = $this
    ->getSession()
    ->evaluateScript("return {$instance}.editor");
  $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'), 'mceButtonActive') !== FALSE) {
    $button
      ->click();
  }
}