2009-10-08 72 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

相关问题