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?
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 iframe
s.
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?