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

rpa
groovy
executescript

#1

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"});


#2

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

Thanks


#3

Actually the real case where we were needed with this functionality is described here.
https://forum.workfusion.com/t/how-to-save-file-on-machine-which-is-running-node/627

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


#4

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


#5

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