问题
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