Get data from web page using JavaScript in BluePrism

柔情痞子 提交于 2019-12-07 14:34:08

问题


Could someone tell me how can I, in Blue Prism, get data into Data Item from web page using action in Navigate stage Invoke JavaScript or Insert JavaSript fragment?

For example I'm using function:

function myFunction()
{var x=document.getelementById("demo").innerHTML;
return x;}

and I'd like to get this return value into Data item in Blue Prism for processing.


回答1:


Unfortunately there is no quick way of doing that, however there is a very easy workaround.

You need to create a "bridge" between JavaScript and Blue Prism, something both technologies can interact with. In this case the simplest bridge is an HTML textbox.

JavaScript can create and write to a temporary, invisible textbox on the page and Blue Prism can spy it and read from it.

I use the following script to add the textbox and/or clear its value...

if (document.getElementById("JSOutput") == null){
    // Add invisible textbox
    var body = document.getElementsByTagName("body")[0];
    var text = document.createElement("input");
    text.id = "JSOutput";
    text.style.display = "none";
    body.insertBefore(text, body.firstChild);
}
else  {
    // Clear invisible textbox
    document.getElementById("JSOutput").innerText = "";
}

... and then the following script to write something to it.

var output = document.getElementById("JSOutput");
output.innerText = "Hello World!"

You can then spy or manually add the element into application modeler:



来源:https://stackoverflow.com/questions/53610246/get-data-from-web-page-using-javascript-in-blueprism

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!