Executes JavaScript code in the current frame or window of the selected WebDriver. Data can be transferred between KNIME and the JavaScript code, by specifying a return type for the executed code and/or selecting input columns which provide argument values for the executed code.
Arguments can be accessed within JavaScript code through the arguments
array. The following argument and return
data types are supported:
JavaScript | KNIME Cell | KNIME Flow Variable |
---|---|---|
HTML Element | WebElement | — |
Decimal Number | Double | Double |
Non-decimal Number | Long | Long, Int |
Boolean | Boolean | Boolean |
String | String | String |
Array | List, JSON | Double, Long, Int, Boolean, String Array |
Object | JSON | — |
The following snippet will return a JSON object which is mapped to a JSON cell in KNIME. For this, set the “Return type” to “JSON”:
const result = { property1: 'a', property2: 2, property3: [ 'b', 'c', 'c' ] }; return result;
In case you need to execute code asynchronously, enable the [asyncCallbackMethod] argument. In this case, the last argument given to the executed code is the callback which signals that the code has finished execution. In case you need to return results from your asynchronous code, provide it as argument to the callback method. For example, the following JavaScript code causes the browser to sleep for five seconds, then the execution continues:
const callback = arguments[arguments.length - 1]; // last argument is callback window.setTimeout(function() { console.log('finished'); callback(); // invoke the callback to continue execution }, 5000);
Timeouts for asynchronous execution can be configured in the Start WebDriver node in the “Timeouts” tab: Script timeout.
arguments
array. Enable the last
entry [asyncCallbackMethod] in case you’re running an asynchronous script to be able to signal end
of execution.You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.
To use this node in KNIME, install the extension Selenium Nodes for KNIME from the below update site following our NodePit Product and Node Installation Guide:
A zipped version of the software site can be downloaded here.
Deploy, schedule, execute, and monitor your KNIME workflows locally, in the cloud or on-premises – with our brand new NodePit Runner.
Try NodePit Runner!Do you have feedback, questions, comments about NodePit, want to support this platform, or want your own nodes or workflows listed here as well? Do you think, the search results could be improved or something is missing? Then please get in touch! Alternatively, you can send us an email to mail@nodepit.com.
Please note that this is only about NodePit. We do not provide general support for KNIME — please use the KNIME forums instead.