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
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/polyblock/capybara_helpers.rb', line 24 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 14 15 16 17 18 19 20 21 22 |
# File 'lib/polyblock/capybara_helpers.rb', line 3 def fill_in_polyblock(locator, params={}) # Find out ckeditor id at runtime using its label # if page.has_css? "##{locator}" if page.evaluate_script("$('##{locator}').is('*')") # elsif page.has_css? 'label', text: locator elsif page.evaluate_script("$(\"label:contains('#{locator}')\").is('*')") locator = find('label', text: locator)[:for] else raise "Locator #{locator} not found!!" end # Fill the editor content page.execute_script " var ckeditor = CKEDITOR.instances['\#{locator}'];\n ckeditor.setData('\#{params[:with]}');\n ckeditor.focus();\n setTimeout(function(){\n ckeditor.updateElement();\n }, 1);\n SCRIPT\nend\n" |