FckEditor 的 Watin 测试
我一直在使用 watin 进行 web 应用程序的集成测试。 Web 应用程序使用 fckeditor 作为富文本控件之一。
这是我的网络应用程序的视图源的 html 片段,其中包括 fckeditor
iframe id="ctl00_HeaderMain_txtSafetyNetDescription___Frame" src="/FCKEditor/editor/fckeditor.html?InstanceName=ctl00_HeaderMain_txtSafetyNetDescription&Toolbar=myApp" width="100%" height=" 200px"frameborder="no"scrolling="no"/iframe
通过使用 watin 脚本...我可以使用以下代码获取框架对象。
Frame frame = ie.Frame(Find.ById("ctl00_HeaderMain_txtSafetyNetDescription___Frame")) ;
现在我想向 fckeditor 写入一些文本。但我不知道如何写入 fckeditor,因为它是一个框架 ——有人可以帮我解决这个问题吗?
谢谢。 艾扬格。
I have been working on the integration testing of a webapp using watin.
The webapp uses fckeditor as one of the richtext controls.
Here is the piece of html of the viewsource of my webapp that includes fckeditor
iframe id="ctl00_HeaderMain_txtSafetyNetDescription___Frame" src="/FCKEditor/editor/fckeditor.html?InstanceName=ctl00_HeaderMain_txtSafetyNetDescription&Toolbar=myApp" width="100%" height="200px" frameborder="no" scrolling="no" /iframe
By using the watin script ... i am able to get the frame object with the following code.
Frame frame = ie.Frame(Find.ById("ctl00_HeaderMain_txtSafetyNetDescription___Frame")) ;
Now I want to write some text to the fckeditor. But i am not sure how to write to the fckeditor as it is a frame
-- can someone help me on this.
Thanks.
Iyyengar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它可以帮助你~
Frame frame = ie.Frame("blogBody-EditingArea");
frame.ElementWithTag("body", Find.Any).SetAttributeValue("innerText", "现在的心情记录" + DateTime.Now);
it can help you ~
Frame frame = ie.Frame("blogBody-EditingArea");
frame.ElementWithTag("body", Find.Any).SetAttributeValue("innerText", "现在的心情记录" + DateTime.Now);
我可以在 Firefox 的帮助下找到 fckeditor 的 watin 测试脚本的解决方案。谢谢火狐。
使用 fck 编辑器,框架内有一个框架。即暴露innerframe但不暴露框架innerhtml。
FireFox 清楚地显示了 dom 树。
Watin 不允许更新para 的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 – 因此需要提供一个 id
para.SetAttributeValue("id", "fckpara");
string fckvalue = "Myfckeditor 文本";
字符串js =“”;
js = js + " document.getElementById('fckpara').innerHTML = '" + fckvalue + "' ;";
我退出了。
谢谢大家。
伊耶格纳尔。
I could find the solution to the watin test script for fckeditor with the help of firefox. Thanks FireFox.
With fck editor there is a frame inside the frame. Ie exposes the innerframe but does not expose the frame innerhtml.
Where as FireFox clearly shows the dom tree.
Watin does not allow updating the innerhtml of para. However it exposes a method called RunScript (great). We can write a JS and execute that for the object.
In this case it is Child Frame.
And that has solved the problem
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 does not id the para – and hence need to be provide with an id
para.SetAttributeValue("id", "fckpara");
string fckvalue = "Myfckeditor text";
string js = " ";
js = js + " document.getElementById('fckpara').innerHTML = '" + fckvalue + "' ;";
I am exited.
Thanks everyone.
Iyyegnar.