使用 Selenium IDE 与 iframe 元素交互的好方法是什么?

发布于 2024-09-04 08:54:34 字数 386 浏览 10 评论 0 原文

我想测试一个在 FCKeditor 的网络应用程序项目/ide/" rel="nofollow noreferrer">Selenium IDE。不幸的是,FCKeditor 使用 iframe,很难在 Selenium IDE 中测试。基本上,我想做的就是设置FCKeditor编辑区的值,然后读取它,看看该值是否提交正确。

我想这个问题有两个方面:首先,有人有针对这个问题的 FCKeditor 特定解决方案吗?其次,有谁知道实现可在 Selenium IDE 测试中使用的自定义 Javascript 函数的好方法吗?

I am wanting to test a web application which uses FCKeditor in Selenium IDE. Unfortunately, FCKeditor uses iframes, which are difficult to test in Selenium IDE. Basically, all I want to do is set the value of the FCKeditor editing area and read it later to see if the value was submitted correctly.

I suppose this question is two-fold: first of all, does anyone have an FCKeditor-specific solution to this problem? and secondly, does anyone know of a good way to implement custom Javascript functions that can be used in your tests in Selenium IDE?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挥剑断情 2024-09-11 08:54:34

我已经想出了一个解决方案。它涉及使用 Selenium IDE 的 storeEval 方法、storedVars 变量和匿名函数。它还利用了 iframeactiveElement 属性。

基本上,我所做的就是使用 javascript 调用 storeEval 方法,将 storedVars 的某个元素设置为我稍后将用作参数的函数。对于 FCKeditor 示例,参数是:

storedVars["setFCKeditorField"] = function (fieldName, value) {var iframe = this.browserbot.findElement("id="+fieldName+"___Frame"); var outerDocument = iframe.contentDocument; var innerDocument = outerDocument.activeElement.contentDocument; var textField = innerDocument.activeElement; textField.innerHTML = value;}

我故意将其格式化,因为这是它在 Selenium IDE 中显示的方式,而我显然不太理想。

然后,稍后,当我真正想要设置 FCKeditor 字段的值时,我使用 javascript 再次调用 storeEval 来调用该函数作为参数,如下所示:

storedVars["setFCKeditorField"].call(this, "SU_ats_subscription_configuration_model[subscription_reminder_message]", "Subscription Expiring Message.<br/>");

这可行,但我希望有一个更好的方法。 Selenium RC 会让这变得容易吗?

I have come up with a solution. It involves using Selenium IDE's storeEval method, storedVars variable, and anonymous functions. It also exploits the activeElement property of the iframes.

Basically, what I do is call the storeEval method with javascript to set a certain element of storedVars to the function I will use later as the argument. For the FCKeditor example the argument would be:

storedVars["setFCKeditorField"] = function (fieldName, value) {var iframe = this.browserbot.findElement("id="+fieldName+"___Frame"); var outerDocument = iframe.contentDocument; var innerDocument = outerDocument.activeElement.contentDocument; var textField = innerDocument.activeElement; textField.innerHTML = value;}

I have formatted it like that on purpose because that is the way it would show up in Selenium IDE, and I it is obviously less than ideal.

Then, later, when I actually want to set the value of the FCKeditor field, I call storeEval again with javascript to call the function as the argument, like so:

storedVars["setFCKeditorField"].call(this, "SU_ats_subscription_configuration_model[subscription_reminder_message]", "Subscription Expiring Message.<br/>");

This works, but I am hoping there is a better way. Would Selenium RC make this easy?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文