Sha256: 0817fca81aca61d06413a593175ed1a17694dfc55f665513358aa3db19dd4379

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

module Polyblock
  module CapybaraHelpers
    def fill_in_polyblock(locator, params={})
      # Find out ckeditor id at runtime using its label
      locator = find('label', text: locator)[:for] if page.has_css?('label', text: locator)
      # Fill the editor content
      page.execute_script <<-SCRIPT
          var ckeditor = CKEDITOR.instances['#{locator}'];
          ckeditor.setData('#{params[:with]}');
          ckeditor.focus();
          ckeditor.updateElement();
      SCRIPT
    end

    def fill_in_inline_polyblock(name, params={})
      page.execute_script <<-SCRIPT
          var element = $('.polyblock[data-pbname="#{name}"]');
          var ckeditor = CKEDITOR.instances[element.attr('id')];
          ckeditor.fire('focus');
          ckeditor.setData('#{params[:with]}');
          ckeditor.focus();
          ckeditor.updateElement();
      SCRIPT
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyblock-0.9.7 lib/polyblock/capybara_helpers.rb