WatiN: How to type text in the Body allocated in o

2019-08-31 17:40发布

This is link to TinyMCE redactor: TinyMCE

I have a task: To type text in the textfield of TinyMCE. 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

标签: watin
4条回答
戒情不戒烟
2楼-- · 2019-08-31 18:10

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.

查看更多
放我归山
3楼-- · 2019-08-31 18:18
string js = "tinyMCE.activeEditor.setContent('tekst');";
browser.Eval(js);
查看更多
欢心
4楼-- · 2019-08-31 18:20

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.
查看更多
贼婆χ
5楼-- · 2019-08-31 18:25

You could set the Text property of the Body element.

查看更多
登录 后发表回答