Skip to content

Instantly share code, notes, and snippets.

@gacha
Created November 1, 2012 19:23
Show Gist options
  • Save gacha/3995845 to your computer and use it in GitHub Desktop.
Save gacha/3995845 to your computer and use it in GitHub Desktop.
Fill in text into tinymce for capybara, using native input for selenium and JS for other
# used as example https://groups.google.com/d/msg/ruby-capybara/XhDAHGjZSjA/VwiW0-2nOIEJ
# IMPORTANT! To do the real simulation you need chrome driver - http://code.google.com/p/selenium/downloads/list, download and add to PATH
def tinymce_fill_in name, options = {}
if page.driver.browser.browser == :chrome
page.driver.browser.switch_to.frame("#{name}_ifr")
page.find(:css, '#tinymce').native.send_keys(options[:with])
page.driver.browser.switch_to.default_content
else
page.execute_script("tinyMCE.get('#{name}').setContent('#{options[:with]}')")
end
end
@thatandyrose
Copy link

This is AWESOME, thanks!

@belguzmani
Copy link

This is exactly what I needed :) Thanks

@jameskerr
Copy link

Very useful!

@rajkosara
Copy link

In my case, i do not have an iframe with name but only with ID
screen shot 2017-03-17 at 11 55 10
and cannot make it work with the above example. Any advise.

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