Inject java script activity error

Facing an error: while using Inject simple “hello” Java script code, throwing an error

This issue also i am getting from version 22.xx onwards

Source: Inject Js Script

Message: Error HRESULT E_FAIL has been returned from a call to a COM component.

Exception Type: UiPath.Core.ElementOperationException

UiPath.Core.ElementOperationException: Error HRESULT E_FAIL has been returned from a call to a COM component. —> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component. at UiPath.UiNodeClass.InjectAndRunJS(String bstrCode, String bstrInputText)
at UiPath.Core.UiElement.InjectAndRunJS(String code, String input)
— End of inner exception stack trace —
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

1 Like

Try to use UiPath.UIAutomation.Activities.23.10.9 and in the Studio project → Project Settings try to change/play with the Run value and Debug value for Inject Js Script - Execution world.

Based on Activities - Inject JS Script

Thank you for your quick response @marian.platonov

I’m not able to get the option for activity settings for inject java script
UI Automation Classic:

UI Automation Modern:

Did you upgrade the UiPath.UIAutomation.Activities to 23.10.9?

Also, try to upgrade the Studio to a higher version (for example 23.10.4) if that option is still not there.

Yes, I have upgraded the activities version, now the option is available, but the issue not yet resolved. Bot throwing error after few seconds before going next activity.

Thank you @marian.platonov

Check the steps from this post Inject Js Script: Error HRESULT E_FAIL has been returned from a call to a COM component - #3 by RobotSJ

Also try to upgrade studio and the browser extension from the new Studio, and add a higher delay before injecting the script.

Hi @kapil.behera,

I had a simular issue where my script was doing what I want correctly.

But, after doing it an exception was thrown.

In my case, I just set the Continue On Error property to True for the Inject Js Script activity to ignore that exception.