The Execute Javascript Integer function expects your code to return, wait for it, an integer.
Just add a line to your code that returns a value and it will work.
window.close();
return 0;
-Andrej
Thanks for your support, Andrej.
I was added this code + add timeout 5s
But, still display the error as below:
Execution started at 20 Aug 2019, 11:11:42 (local Amsterdam time) Execution stoped at 20 Aug 2019, 11:13:28 (local Amsterdam time)
[Nhu][06. RITE Horizon CSC - Dispute]: at 24: [Execute Javascript Integer]: with Script: window.close(); return 0; with Timeout (ms): 5000 Execute Javascript Integer Caused by: com.mansystems.ATS.Runner.exceptions.RunnerException: script timeout: result was not received in 5 seconds (Session info: chrome=75.0.3770.80) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: '185-44-129-55', ip: '185.44.129.55', os.name: 'windows', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_181' Driver info: driver.version: unknown Command duration or timeout: 0 milliseconds at com.mansystems.ATS.Runner.definitions.functions.FunctionImpl.run(FunctionImpl.java:69) at com.mansystems.ATS.Runner.definitions.functions.FunctionImpl$1.run(FunctionImpl.java:37)”
Could you help to check it?
-NhuTrieu
Hi,
I am not sure why you added the timeout, ti is really not needed in this scenario. Timeout is used when you want to execute some javascript asynchronously. Synchronous execution is much simpler and should be preferred unless there is a good reason why it can not be used.
In any case when executing javascritp actions it is good to remember that they are scoped inside a function in the following way
// synchronous
result = function (argument1, argument2 ... ) {
// your code goes in here, when done return the result
};
// asynchronous
function(argument1, argument2, .., callback) {
// your code goes in here, when done call the callback and pass the result
}
So in the case of asynchronous function the javascript code needs to look like this
var callback = arguments[arguments.length-1]; // callback is always the last argument
window.close();
callback(1); // instead of return 1;
Again I would suggest to use the synchronous version without the timeout.
-Andrej
Read more about javascript execution in Selenium here – https://www.guru99.com/execute-javascript-selenium-webdriver.html