Is it possible to pass arguments to `driver.executeScript` for Groovy script?



To execute JavaScript code on Node side and pass there any parameter we are eligible to use the following approach:

((JavascriptExecutor) ieDriver).executeScript("document.querySelector('div[aria-label=\"Message Body\"]').innerHTML = arguments[0];", new Object[]{mailBody});

The second argument of executeScript function might take the list of arguments which are accessible inside javascript you passed as first parameter, i.g. via arguments[0], arguments[1], etc.

The question is: Is there some way to pass parameters inside Groovy executable script?

driver.executeScript("<groovy script where I want to use parameters that was passed outside>", new String[] {"GROOVY"});


It is not supported now. Do you need this functionality?
If it is true, please, provide real case when it is needed.



Actually the real case where we were needed with this functionality is described here.

We found some workaround solution as you can see. But only because required executeScript functionality is not supported now.


Thanks! We will try to provide this functional in the future


Thank a lot. It will be great opportunity for developer.