0

我正在尝试使用 Selenium 测试一个值是否已从服务器加载到 GWT 的 RichTextArea 中。

我正在做

@FindByDebugId("gwt-debug-about-me")
private WebElement aboutMeRichText;

当我发送密钥时,没有问题,文本打印在 RichTextArea 中。

但是当我尝试这个(检索值)时:

aboutMeRichText.getText() 

它返回一个空字符串。

当我查看 HTML 中生成的内容时,它是这样的:

<iframe class="GJUJXOPBLP-com-asdf-asdf-client-resource-Resources-Styles-textBox hasRichTextToolbar" id="gwt-debug-about-me">
#document
<html><head></head><body>Hi there !</body></html>
</iframe>

我该怎么做才能找回“你好!” 文本?

4

1 回答 1

1

它是一个iframe,和 normal 不一样WebElement,所以你需要先切换到它。

driver.switchTo().frame(aboutMeRichText);
WebElement body = driver.findElement(By.TagName("body")); // then you find the body
body.getText();

// get out of the editor
driver.switchTo().defaultContent();
于 2013-08-04T22:15:31.203 回答