public function WysiwygSubContext::iClickTheElementInTheWysiwygEditor in Panopoly 7
Same name and namespace in other branches
- 8.2 modules/panopoly/panopoly_test/behat/steps/panopoly_test_wysiwyg.behat.inc \WysiwygSubContext::iClickTheElementInTheWysiwygEditor()
@When I click the :cssSelector element in the :instanceId WYSIWYG editor
File
- modules/panopoly/ panopoly_test/ behat/ steps/ panopoly_test_wysiwyg.behat.inc, line 129 
- Provide Behat step-definitions for WYSIWYG editor.
Class
Code
public function iClickTheElementInTheWysiwygEditor($cssSelector, $instanceId) {
  $instance = $this
    ->getWysiwygInstance($instanceId);
  $editorType = $this
    ->getSession()
    ->evaluateScript("return {$instance}.editor");
  // TODO: This is tinyMCE specific. We should probably do a switch statement
  // based on $editorType.
  $editor_iframe_id = $instanceId . '_ifr';
  // This Javascript only works on Chrome - not Firefox.
  $javascript = "jQuery('#{$editor_iframe_id}').each(function() {";
  $javascript .= "  jQuery('{$cssSelector}', this.contentWindow.document || this.contentDocument).click();";
  $javascript .= "});";
  $this
    ->getSession()
    ->executeScript($javascript);
}