This should be possible according to the JavaScript Function in the Selenium IDE HTML tests :
<tr> <td>storeEval</td> <td>function(input) {return input.replace('foo', 'bar');}</td> <td>replaceText</td> </tr> <tr> <td>storeEval</td> <td>replaceText('foo')</td> <td>var</td> </tr>
Instead, I get the following exception:
function statement requires a name
After specifying the name, the statement is executed:
<tr> <td>storeEval</td> <td>function replaceText(input) {return input.replace('foo', 'bar');}</td> <td>replaceText</td> </tr>
But the following line cannot find the definition:
replaceText is not defined
I also tried to refer to a variable instead of a function:
<tr> <td>storeEval</td> <td>${replaceText}('foo')</td> <td>var</td> </tr>
But apparently it is still undefined:
null is not a function
I also tried to make an anonymous function:
<tr> <td>storeEval</td> <td>(function (input) {return input.replace('foo', 'bar')})</td> <td>replaceText</td> </tr>
and running it with parentheses:
<tr> <td>storeEval</td> <td>(${replaceText})('foo')</td> <td>var</td> </tr>
Error:
missing ) in parenthetical
and without:
<tr> <td>storeEval</td> <td>${replaceText}('foo')</td> <td>var</td> </tr>
Error:
missing ; before statement