Created
September 9, 2014 23:53
-
-
Save eoinkelly/69be6c27beb0106aa555 to your computer and use it in GitHub Desktop.
A capybara helper to fill in text into a TinyMCE editor instance
This file contains hidden or 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
## | |
# id must be the id attribute of the editor instance (without the #) e.g. | |
# <textarea id="foo" ...></textarea> | |
# would be filled in by calling | |
# tinymce_fill_in 'foo', 'some stuff' | |
# | |
def tinymce_fill_in(id, val) | |
# wait until the TinyMCE editor instance is ready. This is required for cases | |
# where the editor is loaded via XHR. | |
sleep 0.5 until page.evaluate_script("tinyMCE.get('#{id}') !== null") | |
js = "tinyMCE.get('#{id}').setContent('#{val}')" | |
page.execute_script(js) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing @lbraun