2009-10-08 100 views
1

我一直在使用watin進行webapp的集成測試。 webapp使用fckeditor作爲richtext控件之一。FckEditor的Watin測試

這裏是一片我的web應用程序的viewsource的HTML中,包括FCKeditor的

IFRAME ID = 「ctl00_HeaderMain_txtSafetyNetDescription ___框架」 SRC = 「/ FCKEditor的/編輯/ fckeditor.html?實例名= ctl00_HeaderMain_txtSafetyNetDescription &工具欄= MyApp來」 寬=「100%」height =「200px」frameborder =「no」scrolling =「no」/ iframe

通過使用watin腳本...我能夠使用下面的代碼獲取框架對象。

Frame frame = ie.Frame(Find.ById("ctl00_HeaderMain_txtSafetyNetDescription___Frame")) ; 

現在我想寫一些文本到fckeditor。但我不知道如何寫入fckeditor,因爲它是一個框架 - 有人可以幫助我做到這一點。

謝謝。 Iyyengar。

回答

1

我可以在firefox的幫助下找到fckeditor的watin測試腳本的解決方案。感謝FireFox。 使用fck編輯器,框架內有框架。即暴露innerframe但不暴露幀innerhtml。

FireFox在哪裏清楚地顯示了dom樹。
Watin不允許更新段落的innerhtml。但是它公開了一種稱爲RunScript的方法(很棒)。我們可以編寫一個JS併爲該對象執行它。 在這種情況下,它是兒童框架。 並且已經解決了該問題

Frame frame = ie.Frame(Find.ById(「ctl00_HeaderMain_txtSafetyNetDescription ___ Frame」)); Frame ChildFrame = frame.Frame(Find.BySrc(「javascript:void(0)」)); Para para = ChildFrame.Para(Find.ByIndex(0));

// fck editr不會識別該段落 - 因此需要提供一個id para.SetAttributeValue(「id」,「fckpara」); string fckvalue =「Myfckeditor text」; string js =「」; js = js +「document.getElementById('fckpara')。innerHTML ='」+ fckvalue +「';」;

 ChildFrame.RunScript(js); 

我已離開。 謝謝大家。

伊亞格納爾。

2

它可以幫助你〜

幀一幀= ie.Frame( 「blogBody-EditingArea」);

frame.ElementWithTag(「body」,Find.Any).SetAttributeValue(「innerText」,「現在的心情記錄」+ DateTime.Now);

+0

我必須這樣做: var richTextFrame = browser.Frame(WatiN.Core.Find.ByTitle(「Rich text editor,DESCRLONG $ 0,press ALT 0 for help。」)); richTextFrame.Body.SetAttributeValue(「innerText」,「Testing Note Details」); – Omzig 2014-07-14 16:24:01