cancel
Showing results for 
Search instead for 
Did you mean: 

Chrome | BP 6.10.1 | Invoke Javascript failed

sabarirajanm
Level 3
Hello,

Invoke javascript is failed but the same script is working in IE11.
without using sendkey , is possible to find the solution with Invoke script.?

The real problem is:
Once we keystroke value in textbox manually, it will change to green  background. If no value in textbox, it will have red background.

Currently we have red background when we post the value from BP (the value was not consider). Is there any way to trigger the javascript for that textbox class/id/name ?



Regards,
Sabarirajan M

------------------------------
sabarirajan m
------------------------------
1 REPLY 1

Hi Sabariranjan,

'Invoke Javascript' action doesn't work strangely at all times. But a way that I always have used Javascript in my project is by using two 'Insert Javascript' actions where the first action inserts a function definition altogether and the next 'Insert Javascript' action will call that function. Below is an example of how I use it:


17247.png

Going inside this business object now, you can see I have two data items created called, Insert JS Fragment and Invoke JS Fragment.

The Insert JS Fragment has a function definition mentioned which looks for an HTML element with the name attribute as "q" which is the search textbox in google and then writes the value which I am passing through it. Once the value has been written, the code looks for the name attribute as "btnK" which is the search button.

The function is as follows:

function writeText(searchText){
                    document.getElementsByName("q")[0].value = searchText;
                    document.getElementsByName("btnK")[0].click();
}


The Invoke JS Fragment is calling that function while passing the value as well which in my case is : writeText("Blue Prism")

Now in order to execute both these functions one by one I have used one Navigate Stage and have used the action "Insert Javascript Fragment" twice. The first time I am inserting the "Insert JS Fragment" data item and the next time I and again using the same action for inserting the "Invoke JS Fragment" data item.

17248.png
17249.png

In your case also the actions will be similar, the only thing that will change is the JavaScript code where you can use getElementById if you have the ID attribute for which you just need to use the click() function and not write anything. Also, no input parameter would be required to be sent out so your Invoke JS Fragment data item would also be something simple like: function_name()  which in my case was writeText("Blue Prism")


***IMPORTANT NOTICE***

But one thing to note is that Invoke and Insert JS will no longer work when Manifest V3 comes in Chrome and Edge after June 2023.

"As per Manifest V3, In addition, customers should be aware that with MV3, Google (and Microsoft) have removed the capability to perform JavaScript invocation or injection. Customers who utilize that capability must modify their automations to overcome the vendor-imposed restrictions. "


You can find the official thread related to this issue here: Manifest V3 Official Announcement

Hence, what I strongly suggest is in near future you might have to rethink on the solution design and instead try with some other approach like using Send Keys action from Blue Prism, use some other services like Chromium API's which can interact with webpages.

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please provide a big thumbs up so that the others members in the community having similar problem statement can track the answer easily in future.

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Technical Business Analyst,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------