简体   繁体   中英

Get data from web page using JavaScript in BluePrism

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.

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:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM