Monday, May 27, 2013

Selenium IDE & CKEditor recording problem

Its been so long and today i planed to write about a problem and a solution i have faced while i try to record with Selenium IDE and CKEditor.

Problem: 
While recording with selenium IDE it can't record the CKEditor text that was written inside the CKEditor text field.

Solution:
Adding these three line will let the Selenium IDE type into the text box.

Here is the table for the IDE:

focus | class=cke_editable cke_editable_themed cke_contents_ltr
typeKeys | class=cke_editable cke_editable_themed cke_contents_ltr | Automated test text from Selenium IDE
runScript | CKEDITOR.instances["edit-body-und-0-value"].setData('Automated test text from Selenium IDE ');



focus | class=cke_editable cke_editable_themed cke_contents_ltr
This is the class of the CKEditor (please see the screenshot below to know how to find the class of CKEditor by using firebug)

Use firebug to know the class of CKEditor
  • typeKeys | class=cke_editable cke_editable_themed cke_contents_ltr | Automated test text from Selenium IDE


  • typeKeys will focus the CKEditor text field. Here the class is the same class used above. And the text after the class will be written inside the text field of CKEditor.



    runScript | CKEDITOR.instances["edit-body-und-0-value"].setData('Automated test text from Selenium IDE ');

    runScript will run the script that will write inside the text field of the CKEditor. 

    This is the screenshot of IDE if you need more help please let me know. 

    Selenium IDE - CKEditor code

    13 comments:

    1. Replies
      1. Can you please give more info how you did that ? any image will be preferable

        Delete
      2. I have added following commands in my test case, but my problem is that on my page I have a button to save/send some data (from ckeditor too) and when Selenium clicks on Save-button, the written data in ckeditor disappear

        focus | class=cke_show_borders
        typeKeys | class=cke_show_borders | testing content
        runScript | CKEDITOR.instances["editor1"].setData('testContent');

        Delete
    2. I have added following commands in my test case, but my problem is that on my page I have a button to save/send some data (from ckeditor too) and when Selenium clicks on Save-button, the written data in ckeditor disappear

      ReplyDelete
    3. Thank you so much, I was using id-s in my scripts and for some reason couldn't make it work.

      I've focused on iframe class and it worked. Thank you again!

      ReplyDelete
      Replies
      1. How did you do with iframe class?

        Delete
      2. Can you show us an example how did it work with iframe class.

        Delete
      3. Can You send me the sample test script Using iframe..

        Delete
      4. Can you send me a sample test script using iframe to my email id rakesh.singh.pesit@gmail.com.

        Delete
    4. No.. it is still does not work.. send me your email.. i will send you test case..

      ReplyDelete
    5. I'm trying to figure out how to make Selenium record keystrokes in my web app, and found this page, but your solution does not seem to work for me.

      My web app uses keystrokes extensively (by capturing onkeydown in the window object), so I need to be able to capture and replay every keystroke I type in the app. However, nothing I type shows up in the recording, although clicking on other elements does. I understand it is possible to manually add script commands to generate the keystrokes, but this is unacceptable at the present time as this would basically eliminate something like 90% of the usefulness of being able to record in the first place!

      I have modified the above commands to refer to the class of the body of my web app, which I have created especially for this purpose, but the record still does not record my keystrokes, and I am not sure how the above will even help with this as it is a command that isn't going to run until I actually replay the script, which I'm not ready to do yet. Any tips or pointers would be appreciated!

      ReplyDelete
    6. The Information you provided is very much useful for selenium Learners. This Information was very Intersting, We also provide selenium Online training in India.

      ReplyDelete
    7. You are the man bro, it works as a charm.

      ReplyDelete