【问题标题】:Get the value from a RichTextArea in a Selenium test在 Selenium 测试中从 RichTextArea 获取值
【发布时间】:2013-08-07 17:11:11
【问题描述】:

我正在尝试使用 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>

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

【问题讨论】:

  • 我遇到了与 GXT 类似的问题,我试图检索的字段有一个名为“只读”的属性,当设置时我无法检索文本,有点矛盾属性,但尽管如此......你碰巧有这样的东西吗?

标签: gwt selenium webdriver selenium-webdriver selenium-chromedriver


【解决方案1】:

iframe,和普通的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();

【讨论】:

  • @Oliver:你对此有什么反馈吗?它对你有用吗?
猜你喜欢
  • 2018-06-25
  • 2018-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-30
  • 2016-07-07
  • 2014-09-22
相关资源
最近更新 更多