views:

398

answers:

1

I have been working on the integration testing of a webapp using watin. The webapp uses fckeditor as one of the richtext controls.

Here is the piece of html of the viewsource of my webapp that includes fckeditor

iframe id="ctl00_HeaderMain_txtSafetyNetDescription___Frame" src="/FCKEditor/editor/fckeditor.html?InstanceName=ctl00_HeaderMain_txtSafetyNetDescription&Toolbar=myApp" width="100%" height="200px" frameborder="no" scrolling="no" /iframe

By using the watin script ... i am able to get the frame object with the following code.

    Frame frame =  ie.Frame(Find.ById("ctl00_HeaderMain_txtSafetyNetDescription___Frame"))  ;

Now I want to write some text to the fckeditor. But i am not sure how to write to the fckeditor as it is a frame -- can someone help me on this.

Thanks. Iyyengar.

+1  A: 

I could find the solution to the watin test script for fckeditor with the help of firefox. Thanks FireFox. With fck editor there is a frame inside the frame. Ie exposes the innerframe but does not expose the frame innerhtml.

Where as FireFox clearly shows the dom tree.
Watin does not allow updating the innerhtml of para. However it exposes a method called RunScript (great). We can write a JS and execute that for the object. In this case it is Child Frame. And that has solved the problem

Frame frame = ie.Frame(Find.ById("ctl00_HeaderMain_txtSafetyNetDescription___Frame")) ; Frame ChildFrame = frame.Frame(Find.BySrc("javascript:void(0)")) ; Para para = ChildFrame.Para(Find.ByIndex(0));

// fck editr does not id the para – and hence need to be provide with an id para.SetAttributeValue("id", "fckpara"); string fckvalue = "Myfckeditor text"; string js = " "; js = js + " document.getElementById('fckpara').innerHTML = '" + fckvalue + "' ;";

        ChildFrame.RunScript(js);

I am exited. Thanks everyone.

Iyyegnar.

Iyyengar