lib/polyblock/capybara_helpers.rb in polyblock-0.9.6 vs lib/polyblock/capybara_helpers.rb in polyblock-0.9.7
- old
+ new
@@ -1,15 +1,26 @@
module Polyblock
module CapybaraHelpers
- def fill_in_polyblock(locator, params = {})
+ 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()
+ 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