This is a migrated thread and some comments may be shown as answers.

[Solved] How can I test the MVC editor control with selenium

1 Answer 87 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jesse Sanders
Top achievements
Rank 1
Jesse Sanders asked on 10 Nov 2010, 02:06 AM
Hi,

I have written tests for the RadEditor with Selenium, however, I am unable to get the tests to work for the MVC version.  Here are my helper functions that work for the RadEditor.  Does anyone have any ideas on how to make this work for MVC?


        public static void TypeRadEditor(this ISelenium selenium, string editorId, string text)
        {
            selenium.RunScript(string.Format("$find('{0}').set_html('{1}')", editorId, text));
        }

        public static string GetTextRadEditor(this ISelenium selenium, string editorId)
        {
            return selenium.GetEval(string.Format("this.browserbot.getCurrentWindow().$find('{0}').get_html()", editorId));
        }

I can get to the object by using $('#editor').data('tGrid') with jquery, however, that doesn't seem to help me with being able to get and set text in the editor using selenium.

Any thoughts on how I can get this to work?

Thanks,

Jesse

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Nov 2010, 07:57 AM
Hi Jesse Sanders,

 You can check the client-side API help topic for the editor which shows how to get and set the html of the editor. The code you should try is this:

public static void TypeRadEditor(this ISelenium selenium, string editorId, string text)
{
    selenium.RunScript(string.Format("$('#{0}').data('tEditor').value('{1}')", editorId, text));
}
 
public static string GetTextRadEditor(this ISelenium selenium, string editorId)
{
    return selenium.GetEval(string.Format("this.browserbot.getCurrentWindow().$('#{0}').data('tEditor').value()", editorId));
}

Make sure you are prefixing the id of the editor with "#" which is required by jQuery.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Editor
Asked by
Jesse Sanders
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or