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 |
---|---|
HTML element | WebElementValue |
Decimal | DoubleValue |
Non-decimal | LongValue |
boolean | BooleanValue |
String and other cases | StringValue |
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:
var callback = arguments[arguments.length - 1]; // last argument is callback window.setTimeout(function() { console.log('finished'); callback(); // invoke the callback to continue execution }, 5000);
Hint: In case you want to return complex data from your JavaScript code (objects or arrays), you can serialize them as follows and use the return type “String”:
var complexObject = { property1: 'foo', property2: [ 'bar', 'baz' ], property3: 5 }; return JSON.stringify(complexObject);
Afterwards, you can make use of KNIME’s String to JSON node to convert the string into a JSON cell.
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.