【问题标题】:Can HtmlUnit support to set the content to an online rich text editor?HtmlUnit 是否支持将内容设置为在线富文本编辑器?
【发布时间】:2012-02-26 12:14:47
【问题描述】:

我正在使用 HtmlUnit 来测试一个 Web 应用程序。它使用在线富文本编辑器来收集用户输入。 (使用 iframe 时没有 src 属性)。我必须模拟用户输入,但我发现我无法将内容设置到这个 iframe 中。

HtmlUnit 可以支持这个功能吗?我在网上搜索了很多,但没有找到明确的答案。

【问题讨论】:

    标签: javascript iframe htmlunit rte


    【解决方案1】:

    一种方法是通过 JavaScript 设置它。

    String jsCode = String.format("tinyMCE.activeEditor.setContent('this is my comment');");
    ((JavascriptExecutor) drone.getDriver()).executeScript(jsCode);
    

    查看是否设置了评论。

    WebElement iframe = driver.findElement(By.id("the-iframe-id"));
    driver.switchTo().frame(iframe);
    String value = drone.find(By.tagName("p")).getText();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-22
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多