I am trying to automatically insert some text using Selenium/Webdriver into a text box created using tinymce
The text box is not a plain vanilla textbox so following
There are multiple ways of doing it. Here's an article you might want to have a look.
Test WYSIWYG editors using Selenium WebDriver
Code snippets below are not tested, only provide the logic in Java.
inputWebDriver.switchTo().frame("input-data_ifr");
WebElement element = inputWebDriver.findElement(By.cssSelector("body"));
element.sendKeys("Send keys");
inputWebDriver.switchTo().frame("input-data_ifr");
WebElement element = inputWebDriver.findElement(By.cssSelector("body"));
(JavascriptExecutor)driver.executeScript("arguments[0].innerHTML = 'Set text using innerHTML
'", element);
// no need to switch iframe
(JavascriptExecutor)driver.executeScript("tinyMCE.activeEditor.setContent('Native API text
TinyMCE')");