Is there a way in Robot Framework to run a javascript method that returns a promise and resolve that promise so I could get a result from it? I tried to achieve it in two ways. The first way was to run the Execute Javascript
keyword and pass the function, then set wait for some time (with Sleep
) and trying to resolve the promise (it already finished to execute in the browser).
The code I used looks like that:
${promise}= Execute Javascript return runAllTests();
Sleep 30sec
${result}= Set Variable return ${promise}.then(function(result) { return result; });
The result I got with this was just the promise object (I think)
{u'all': {}, u'_setSettlePromisesQueued': {}, u'_setBoundTo': {}, u'_settlePromiseAtPostResolution': {}, u'_isRejectionUnhandled': {}...
I do not paste it all because it's 3000+ characters long, but it's not what I expected for sure. Actually, the result is exactly the same no matter if I put there Sleep
keyword or not.
The second way was to use Execute Async Javascript
keyword (with modified timeout) and then trying to resolve it.
Set Selenium Timeout 30sec
${result}= Execute Async Javascript return runAllTests().then(function(result) { return result});
The function finished to execute in the browser window, but Robot seems not to care and after 30 seconds it reports TimeoutException
with this message:
TimeoutException: Message: asynchronous script timeout: result was not received in 30 seconds
I tried to find another way, maybe some built-in mechanism to handle the promises, but I did not find anything like that. Is there any way to do that? I use Robot with Selenium2Library.