- selenium切换到iframe中
driver.switchTo().frame("wysiwygTextarea_ifr");
- 执行JS
WebElement content = driver.findElement(By.id("tinymce")); //内容区域
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].innerHTML = '<h1>Selenium Test </h1>'", content);
- 最后再切换出iframe
driver.switchTo().defaultContent();