Module: Polyblock::CapybaraHelpers

Defined in:
lib/polyblock/capybara_helpers.rb

Instance Method Summary collapse

Instance Method Details

#fill_in_polyblock(locator, params = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/polyblock/capybara_helpers.rb', line 3

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