Created
April 18, 2013 21:55
-
-
Save racheldonovan/5416557 to your computer and use it in GitHub Desktop.
a helper to assit in integration testing (rspec / capybara) wysihtml5 text editors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Wysihtml5Helper | |
def fill_in_wysihtml5(text) | |
#js must be enabled | |
page.execute_script("editor.setValue('#{text}')") | |
end | |
end |
@dannio you can use the following in order to access the editor of a specific element:
var editor = $('#some-textarea').data("wysihtml5").editor;
editor.getValue();
editor.setValue('Test');
You are my hero. Was going nuts trying to interact with this in Capybara.
Getting
ReferenceError: Can't find variable: editor
Assuming it's not instantiated yet, though it certainly should be...
(Thanks to @zedtux) if you got ReferenceError: Can't find variable: editor
, you can try this:
page.evaluate_script %{(function() {
var editor = $('.test-textarea').data("wysihtml5").editor;
editor.getValue();
editor.setValue('A text');
})()}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This only selects the last editor on the page right? What about if there were multiple editors?