rpa 增加 js 调用接口
下载适用 6.1 版本, 7.0 自带该接口
用户现场需求,需要调用 ie 页面中的部分 js 数据,所以额外增加 js 调用接口f6a296cb96084cc7a47f5613b395ab6c_UEBAIEWatcher.dll
本次测试调用 js 样例,通过setResuilt
处理 js 调用最后结果,交给 python 处理
1、需要开始时初始化至 loadingsetResult('loading')
2、js 执行结束时,通过setResuilt
返回结果给 pythonsetResult('false');
执行失败setResult('true');
执行成功
完整 js 脚本如下:
function setResult(result){
var resultElement=document.getElementById('isearch-ret');
if(resultElement){
resultElement.setAttribute('result',result);
}else{
resultElement =document.createElement('input');
resultElement.setAttribute('id','isearch-ret');
resultElement.setAttribute('result',result);
document.body.appendChild(resultElement);
}
}
setResult('loading');
$.post('/rezerwacje/reservations/lock',{time:'2018-09-12 10:00:00',queue: 200035}).done(function (data){
console.log(data);
slot = data.replace('OK ', '');
var url = '/rezerwacje/reservations/updateFormData/1slot1/200054';
if (data == 'FAIL'){setResult('false');
Materialize.toast('This time is locked by other user!',2000);
time_locked = true;
$('#dateContent').load(last_url);
return false;
}else{setResult('false');
window.location.href = url.replace('1slot1',slot);
time_locked = false;
return true;
}
});
iie.joinJs(url=r'https://kolejka-wsc.mazowieckie.pl/rezerwacje/pol/queues/200035/200054',js='function setResult(result){var resultElement=document.getElementById(\'isearch-ret\');if(resultElement){resultElement.setAttribute(\'result\',result);}else{resultElement =document.createElement(\'input\');resultElement.setAttribute(\'id\',\'isearch-ret\');resultElement.setAttribute(\'result\',result);document.body.appendChild(resultElement);}} setResult(\'loading\');$.post(\'/rezerwacje/reservations/lock\',{time:\'2018-09-12 10:00:00\',queue: 200035}).done(function (data){console.log(data);slot = data.replace(\'OK \', \'\');var url = \'/rezerwacje/reservations/updateFormData/1slot1/200054\';if (data == \'FAIL\'){setResult(\'false\');Materialize.toast(\'This time is locked by other user!\',2000);time_locked = true;$(\'#dateContent\').load(last_url);return false;}else{setResult(\'false\');window.location.href = url.replace(\'1slot1\',slot);time_locked = false;return true;}});',waitfor=10,pid=0)