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:
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.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 futureRegards,Devneet MohantyIntelligent Process Automation Consultant | Sr. Consultant - Automation Developer,WonderBotz India Pvt. Ltd.Blue Prism Community MVP | Blue Prism 7x Certified ProfessionalWebsite: 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 this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.