Having Issue with InjectJS

Hello Expert,

Im currently trying to inject a js function that i get from the website itself which is:


When i paste the script in the DOM console, it is working fine and it able to navigate the page

but when i try to use InjectJS using the same script, nothing happen no error or nothing, even in the console in the DOM doesnt reflect anything

I dont really have much knowledge on js. So im not sure if what im doing is correct

Any code you want to run in the browser must be inside anonymous function. Try “function () {
// your code
}”

@Nizri_Daniel

You have to actually write the js function and pass that js function in the activity

Please check this

Cheers

What would be the correct full script, when i put the function inside the error not defined is produced, even when i remove the javascript: it also produce the same error

Hi @Anil_G ,

So meaning we need to know what the script for the function is and then paste that into the injectjs, whats the easiest way to know whats the script for the function displaytraninquiry()

@Nizri_Daniel

You can indicate whole of the window as well…and atleast one argument is to be given I believe…as Of now I see you are not indicating anything…give atleast. One argument and create a function and insite it call the java script you needed on the page

So indicate whole window

Then function as below

Function(e)
{
Can include logs to check if this is being invoked
Call the function you need here- displaytraninquiry();
}

Cheers

Hi,

How about the following?

@"function(e,v){displayTranInquiry();}"

Set Page at ExecutionWorld property

Regards,

Hello @Yoichi ,

I dont seem to have the UIAutomationNext package. How to install the package, i cant seem to find it in the manage packages

Hi,

If you need to use classic activities, it will be as the following. It may be necessary to upgrade UiAtuomation package.

Regards,

1 Like

Thank you @Yoichi

Im able to execute the js function using your method. But if you dont mind are you able to explain a little bit what function (e,v) is and executionworld do

HI,

function(e,v) : e is assigned element which is indicated by InjectJSscriptActivity. v is assigned from parameter property of InjectJSscriptActivity. We can omit these arguments. ( function() also works in this case)

Regarding executionworld property, the following official document will help you.

https://docs.uipath.com/activities/other/latest/ui-automation/inject-js-script

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.