Typing into TinyMCE with Selenium

Since TinyMCE has a questionable behaviour, because it creates an iframe to render the editor, SeleniumIDE has some problems with it.

If you record a test typing into the editor, then, when you’ll run it, it will miserably fail: that’s because, when recording the test, Selenium isn’t able to detect that you have typed in a iframe.

So, if your form’s textarea has the myTextarea id, the iframe TinyMCE will output in order to enrich the textarea will have the same id, with a _ifr suffix.

So you need to tell selenium to focus on that iframe:

1
2
3
4
5
<tr>
  <td>focus</td>
  <td>myTextarea_ifr</td>
  <td></td>
</tr>

then you’ll need to type into the iframe body:

1
2
3
4
5
<tr>
  <td>type</td>
  <td>tinymce</td>
  <td>My text into TinyMCE</td>
</tr>

Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 160+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $9.99

In the mood for some more reading?

...or check the archives.