JS Activity inject

Hello All,

I am using InjectJS script. But for the ScriptOutput, my result is blank.
But if i excute tha same code into the DOM, i get a selector.
You can see below the function i am trying to use as a test:

function test()
{
var test3 =document.querySelector(‘div,class’);
return test3;
}

Thank you in advance for your help.

@Ndiaye_seydina_mouha Welcome to the forum
Can you Post your xaml or inject js configuration settings as a Screenshot.

In Case of you are interacting with a Public Website please Share url as well

@ppr thank you.
Indeed i am interacting with the site of UIPATH: https://www.uipath.com
See below my config of inject js.


So you can see also my xaml.
Main.xaml (7.8 KB)

many thanks.

OK i will have a look in IT. Give me some little time as currently i have to Pass some train stations

@ppr ok sounds good. Thanks

@Ndiaye_seydina_mouha
There are too much infrastructure Issues (Tunnels, interupted Internet…) so I had to change my plans to support you: Lets type In some text and test if its returned

Just do following test and do some changes in the XAML (Backup old Version before)

  • please ensure that on injectjs activity the setting InputParameter empty (really blank, no Nothing, No “”)
  • then use following "function demo() { var msg=prompt(); return msg;} " as JavaScript
  • ensure that ScriptOutput Variable is set (and defined as String Datatype)
    then use a Message Box and let displayed the value of the ScriptOutput Variable

The Idea about the test is to verify if the possible imp allows to:

  • execute the javascript - we do see the prompt Box from JavaScript
  • verify if we got an output and can use it

If this is working then maybe the result from your initial javascript code is not ready to get returned as it is undefined, is not a string …

So can you please just test at your end? Thanks

Hello @ppr!
i have tested with the JS provided and it work. But as output, i still have a blank message with the message box.

@Ndiaye_seydina_mouha
Please help me for understanding:
"function demo() { var msg=prompt(); return msg;} " – this was working, right?
unction test()
{
var test3 =document.querySelector(‘div,class’);
return test3;
} – this is returning empty output (can be confirmed by debugging as well), right?

Then I would suggest to rewrite your initial Javascript function that it is returning a reliable string value e.g. String Value, serialized Javascript Object …

@ppr the function you gave work . i mean the Inject Js is working. And i set the ScriptOutput as string and if i use a message box to display the variable, the result is empty.
Ok i will modify my function .
Many tkanks.