JavaScript Code Inject

How Can i use JavaScript Code in Attach Window Activity. I tried Inject JS but it doesn’t work.Any Suggestion on this?

what was done, what was failling

When newly working with Inject JS we would recommend the following

  • respect and do not change the argument names and usages as described in the docu
function (element, input) {
    return "result";
  • bring forward it in a next iteration to alert the input
  • bring forward it in a next iteration to alert the input and some element details (e.g. a string property)

When this is working begin with the integration of your custom code

I was trying to scroll a page till mid of page.So I though of using JS code to achive this.Because this code need to be generic as i have to same code for various webpage.Any suggestion. Below is the code I tried
const body = document.body;
const html = document.documentElement;
const height = Math.max(body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight);
const midheight = height/2;
It works well when i use Attach Browser but not in Attach Window.

in general is not used for browsers

You mean to say that Inject JS will work with Attach Window also.

It was said:

Typically we use Attach browser for Browsers
And your code snippet was related to a body from a webpage offered by a browser

Can you help me How can I achieve this?

as mentioned above we gave an iteration plan to bring sample code to custom code, when working newly with inject JS

Can I use JS Code in inject JS Activity without using Function Call in UiPath?

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