Skip to content

Instantly share code, notes, and snippets.

@eoinkelly
Created September 9, 2014 23:53
Show Gist options
  • Save eoinkelly/69be6c27beb0106aa555 to your computer and use it in GitHub Desktop.
Save eoinkelly/69be6c27beb0106aa555 to your computer and use it in GitHub Desktop.
A capybara helper to fill in text into a TinyMCE editor instance
##
# 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
@elissonmichael
Copy link

elissonmichael commented Oct 21, 2020

Thanks for sharing @lbraun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment