Skip to content

Instantly share code, notes, and snippets.

@zedtux
Forked from bguthrie/fill_in_wysihtml5.rb
Last active May 17, 2017 18:19
Show Gist options
  • Save zedtux/019927fc8fd4d29572f06375dc15928d to your computer and use it in GitHub Desktop.
Save zedtux/019927fc8fd4d29572f06375dc15928d to your computer and use it in GitHub Desktop.
A Capybara helper to fill in WYSIHTML5 editors. Works with multiple editors on a page.
module FillInWysihtml5Helpers
def fill_in_wysihtml5(label, options = {})
page.execute_script <<-JAVASCRIPT
var id = $("label:contains(#{label})").attr("for");
$("#" + id).data("wysihtml5").editor.setValue("#{options[:with]}");
JAVASCRIPT
end
def read_wysihtml5(label)
page.execute_script <<-JAVASCRIPT
var id = $("label:contains(#{label})").attr("for");
$("#" + id).data("wysihtml5").editor.getValue();
JAVASCRIPT
end
end
World(FillInWysihtml5Helpers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment