繁体   English   中英

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

[英]What is a good way to interact with iframe elements using Selenium IDE?

我想测试一个在Selenium IDE中使用FCKeditor的Web应用程序。 不幸的是,FCKeditor使用iframe,很难在Selenium IDE中进行测试。 基本上,我要做的只是设置FCKeditor编辑区域的值,然后稍后阅读以查看该值是否正确提交。

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

我想出了一个解决方案。 它涉及使用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可以简化这一过程吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM