Inject Javascript with references to other Js files (13.5 KB) Team,

I have a task to Inject java script into a Hmtl page and execute the java script code which returns the output. HTML page has a reference to an external Crypto JS file under its head section.

Though I have references to the Crypto JS script added in the head section, when I inject the javascript that particular part of the java script which uses objects from Crypto JS file is throwing a reference error.But, when I directly put everything into an HTMl file and open the HTML file in the browser, The javascript code is getting executed properly.

I am also able to inject javascript into the HTML file and retrieve the returned value by commenting the two lines of code which references Crypto JS using the Inject JS activity.

Could you please help me in solving this issue. I have attached a Zip folder with the xaml file and also the HTMl and javascript files.please find the attachment.
FIles in the zipped folder are as follow

Base_HTML- HTML page on which javascript will be injected.
Full_HTML_WithcryptoJsworking- HTML page with Javascript code already embedded in it. This works fine. This is for your reference.
With_CryptoJS_code- This is a javascript file with the full javascript code. This is the file I need to inject and get the returned value.
Without_CryptoJS_Code- This is also a javascript with two linnes of code commented. this can be injected and is working fine.
@aksh1yadav @vvaidya @badita

I think the are still better ways to go about this…I will explain it when next im here…not very free now…

Hey @niteesh2004

There could be a possible reasons one is script is not loading before your Js code is getting inserting inside, So you are getting Crypto reference error.

I have modified it a very lil bit and it is working at my end.

Just for your Reference - (22.0 KB)

Note - I have tested with IE.
There might be a security change you have to do if you are running it offline to allow to run offline Active x scripts.

To turn off the Active control message to allow scripts execution.

To turn off the message:

  1. Tools > Internet Options > Advanced Tab

  2. Enable the security option “Allow active content to run in files on My Computer”

  3. Click Apply, Ok