开发者

WatiN: How to type text in the Body allocated in other Frame

开发者 https://www.devze.com 2023-01-03 07:21 出处:网络
This is link to TinyMCE redactor: TinyMCE I have a task: To type text in the textfield of TinyMCE开发者_Python百科. But this in not a textfield, this is a Body that doesn\'t have a method \"TypeText(

This is link to TinyMCE redactor: TinyMCE

I have a task: To type text in the textfield of TinyMCE开发者_Python百科. But this in not a textfield, this is a Body that doesn't have a method "TypeText();"

Please show me the code example, that can type the text in the TinyMCE Body


string js = "tinyMCE.activeEditor.setContent('tekst');";
browser.Eval(js);


tinyMce and watin don't play well together. I generally have to use a combination of javascript (using browser.eval) and the setAttributeValue('value') of textfield objects.


You could set the Text property of the Body element.


I was in a similar scenario (different editor / same concept) and got the body text set via javascript

string js = "document.getElementById('theEditor').contentWindow.document.body.innerHTML = 'Hello World!';";
myEditorPage.RichTextEditor.Eval(js);

Notes about the above code

  • 'theEditor' is the ID of the editor frame.
  • myEditorPage is a Page class I created
  • RichTextEditor is the Frame object in my page class that corresponds to the 'theEditor' IDed frame.

Works like a champ.

My scenario

  • IE8
  • Win7
  • Watin2.0
  • Some 3rd party editor I don't remember.
0

精彩评论

暂无评论...
验证码 换一张
取 消