I'm evaluating Watir-webdriver, to decide if i can switch to using it for my browser tests (from Watir mostly) and one of the key things would be the ability to interact with TinyMCE WYSIWYG editors, as a number of the applications I work with use TinyMCE. I've managed to get the following solution working -
@browser = Watir::Browser.new(:firefox)
@browser.goto("http://tinymce.moxiecode.com/tryit/full.php")
autoit = WIN32OLE.new('AutoITX3.Control')
autoit.WinActivate('TinyMCE - TinyMCE - Full featured example')
@browser.frame(:index, 0).body.click
autoit.Send("^a") # CTRL + a to select all
autoit.Send("{DEL}")
autoit.Send("Some new text")
The drawback of this approach, is that by using autoit, I remain dependent on Windows and the ability to run tests cross-platform is one of the attractions of webdriver.
I noticed some webdriver specific solutions such as the following from this thread:
String tinyMCEFrame = "TextEntryFrameName" // Replace as necessary
this.getDriver().switchTo().frame(tinyMCEFrame);
String entryText = "Testing entry\r\n";
this.getDriver().findElement(By.id("tinymce")).sendKeys(entryText);
//Replace ID as necessary
this.getDriver().switchTo().window(this.getDriver().getWindowHandle());
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.getDriver().findElement(By.partialLinkText("Done")).click();
Which looks like it might work cross-platform but I don't know if the same functionality can be accessed from within Watir-webdriver. My question is, is there a way to write, delete and submit into TinyMCE using watir-webdriver, which will not enforce a dependency on a specific supported browser or operating system?