Monday, December 7, 2009

Using the RadEditor with Fitnesse

Since moving over to the WebDriver code for Fitnesse as a fixture, including the SpiderFixture extension, I have had better luck in getting some additional tasks to work. One item I had been trying to do in Selenium, and never could get it to work, was in making entries into the RadEditor we use on the SharePoint server the product runs on. With WebDriver there is an option to Execute JavaScript, I don't think it does well with multiple lines but I hadn't tried very hard to get things working in that way; what I ended up with was a single line of JavaScript that finds the iframe, adds the text then moves back to the base frame. The frame moving took me a few minutes to realize, once you move to a particular frame on the page going back to the base frame is a good follow-up.

For those who can use it, the JavaScript to get the RadEditor to work is:
execute javaScript $find(${RadEditoriFrame}).set_html(${test_text});

My RadEditoriFrame was set up as: ctl00_PlaceHolderMain_zoneMain_ctl00_txtPost

Best way to verify that this is the one to use, especially on SharePoint, is to use an Object Viewer on the page and verify the editor box is highlighted.

Hope that helps you out, it took me awhile to get this working.

No comments: