Can't sendKeys() to TinyMCE with Selenium WebDriver
Yes, as what Richard says, this is a duplicate of How to input text into tinceMCE editior using selenium/webdriver.
For your specific code, I'd suggest
Try different locator for
mceContentBody
, e.g useBy.cssSelector(".mceContentBody")
,By.cssSelector("body")
, etc.Click the body first before sending keys.
driver.findElement(By.tagName("body")).click().sendKeys("YOOOO");
- Set innerHTML
inputWebDriver.switchTo().frame("input-data_ifr");
WebElement element = inputWebDriver.findElement(By.cssSelector("body"));
(JavascriptExecutor)driver.executeScript("arguments[0].innerHTML = '<h1>Set text using innerHTML</h1>'", element);
- Use TinyMCE's native API
// no need to switch iframe
(JavascriptExecutor)driver.executeScript("tinyMCE.activeEditor.setContent('<h1>Native API text</h1> TinyMCE')");
Further reading: Test WYSIWYG editors using Selenium WebDriver