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

僤鯓⒐⒋嵵緔 提交于 2019-12-12 01:58:20

问题


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


回答1:


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



回答2:


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:


You could set the Text property of the Body element.




回答4:


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.


来源:https://stackoverflow.com/questions/3003973/watin-how-to-type-text-in-the-body-allocated-in-other-frame

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!