Module: Polyblock::CapybaraHelpers
- Defined in:
- lib/polyblock/capybara_helpers.rb
Instance Method Summary collapse
- #fill_in_inline_polyblock(name, params = {}) ⇒ Object
- #fill_in_polyblock(locator, params = {}) ⇒ Object
Instance Method Details
#fill_in_inline_polyblock(name, params = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/polyblock/capybara_helpers.rb', line 15 def fill_in_inline_polyblock(name, params={}) page.execute_script " var element = $('.polyblock[data-pbname=\"\#{name}\"]');\n var ckeditor = CKEDITOR.instances[element.attr('id')];\n setTimeout(function(){\n ckeditor.fire('focus');\n ckeditor.setData('\#{params[:with]}');\n ckeditor.focus();\n ckeditor.updateElement();\n }, 1);\n SCRIPT\nend\n" |
#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 " var ckeditor = CKEDITOR.instances['\#{locator}'];\n ckeditor.setData('\#{params[:with]}');\n ckeditor.focus();\n ckeditor.updateElement();\n SCRIPT\nend\n" |