0

我試圖用Selenium測試是否已經從GWT中的RichTextArea中的服務器加載了一個值。在Selenium測試中從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> 

我應該怎麼做才能找回文本?

+0

我碰到與GXT類似的問題,即場我試圖找回有一個名爲屬性爲「只讀」,這集的時候我不能檢索文字,那種矛盾的屬性,但是儘管如此......你碰巧有這樣的事情嗎? –

回答

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(); 
+0

@Oliver:你對此有任何反饋嗎?它對你有用嗎? –

相關問題