lib/polyblock/capybara_helpers.rb in polyblock-0.9.9 vs lib/polyblock/capybara_helpers.rb in polyblock-1.0.0
- old
+ new
@@ -1,15 +1,24 @@
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)
+ # 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 <<-SCRIPT
var ckeditor = CKEDITOR.instances['#{locator}'];
ckeditor.setData('#{params[:with]}');
ckeditor.focus();
- ckeditor.updateElement();
+ setTimeout(function(){
+ ckeditor.updateElement();
+ }, 1);
SCRIPT
end
def fill_in_inline_polyblock(name, params={})
page.execute_script <<-SCRIPT