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?