You are here

public function FeatureContext::iExpandTheToolbarInTheWysiwygEditor in Bear 7

@When /^I expand the toolbar in the "([^"]*)" WYSIWYG editor$/

File

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

Class

FeatureContext
Defines application features from the specific context.

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();
  }
}