Selenium IDE and TinyMCE

8

Posted by nick | Posted in Selenium | Posted on Oct 06 2008

Tags: , ,

I created a test case for creating a support ticket.  Our support ticket interface has multiple tinymce editors present for the various ticket description and action update fields.  I had a difficult time find a solution that would make Selenium IDE type text into one of these tinymce editors, but I found one that worked using the dom.  Use command “type” and target should be “dom=document.getElementById(’id_of_the_tinymce_frame’).contentDocument.body” and the value can be any text you want entered into the tinymce editor.

Note - if you copy and paste the dom code above, you may have to redo the single quotes around the id after you paste it somewhere else.  I did this and the character changed and threw me off for a bit.

  • Share/Bookmark

Comments (8)

[...] for most of it’s text inputs I had to find a way to write to it within the tests. With Selenium Nick Bartlett had a solution. For WatiN I used the Eval method and executed the setContent JavaScript method in the TinyMCE [...]


Hi!

I just tried this code:
selectFrame(’id_of_the_tinymce_frame’)
// TinyMCE puts an ID of ‘tinymce’ on the body tag of the frame.
// We want to send our type there for tinymce to pick it up and handle it.
focus(’tinymce’)
type(’tinymce’, ‘The text you want to input’)
selectFrame(’relative=parent’)
It worked fine until you had 2 or more TinyMCEs on the same page.

This code worked with multiple TinyMCEs:
“dom=document.getElementById(’id_of_the_tinymce_frame’).contentDocument.body”

Thanks a lot!


[...] Nick Bartlett » Blog Archive » Selenium IDE and TinyMCE. [...]

Thanks a lot, that saved a day. Please keep this site up and running, may will find it useful. Thanks, agian.

For those that actually want to use selenium for cross browser testing (you know what it was designed for), use the following sets of commands, works in FF3, IE6 and IE7 with the latest selenium and tinymce

selectFrame(’id_of_the_tinymce_frame’)
// TinyMCE puts an ID of ‘tinymce’ on the body tag of the frame.
// We want to send our type there for tinymce to pick it up and handle it.
focus(’tinymce’)
type(’tinymce’, ‘The text you want to input’)
selectFrame(’relative=parent’)


contentDocument doesn’t work in IE.

Those of you who are testing in IE should use:

dom=document.getElementById(’id_of_the_tinymce_frame’).contentWindow.document.body

By default “id_of_the_tinymce_frame” appears to be the “name” of the textarea, followed by an underscore, followed by the three letters “ifr”. Posting here since it wasn’t obvious to me. Thanks for the tip though, it works.

For me, “id_of_the_tinymce_frame” was the textarea’s “id” followed by “_ifr”. Thanks!

Write a comment