With 21.10 we used the Inject JS Activity in a few cases to call JS Functions from a webpage. To do this, we used the pattern suggested here:
this worked reliably. When debugging the same code in Studio 22.10.4 the Inject JS Activity now appears to do nothing (no exception, but also not invoking the desired function).
Trying the pattern suggested here:
also did not yield the desired result. The activity returns a reference error (“func() is not defined”). I did pay attention to the selectors. The surrounding “Attach Browser” Scope targets chrome.exe and for the target of the Inject JS Activity itself, i tried both leaving it empty as well as having it target the html-tag of the website containing the script.
Can JS functions on a website still be invoked in 22.10.x and if yes, how can it be done?
this calls a logout function from a webpage. Could be easily replaced with an interface click.
Not so in other cases: "function() {window.location.assign("""+ in_str_JSFunction +""");}"
where I use it to open sub pages I previously obtained by data table scraping.
The elements marked in yellow call JS Functions which open pages where the robot needs to perform some tasks. Scraping the functions and opening them via the inject gives me a very convenient and reliable way to iterate over the pages. The table otherwise gives me very little options to keep track of where i currently stand, if I had to iterate over the pages with the click-activity (the table might grow, due to new datasets being created while the bot works and the Seq-Numbers start with 1 for each new page, so the number doesn’t help either with identifying what I have already done).
Hello @Nithinkrishna
Thanks for trying it out. I suppose the usual method refers to this one? "function() {window.location.assign(""javascript:myFunc();"");}"
I am not sure what you mean by “please post your updates”. Do you want me to keep you updated on my progress resolving this issue or do you want to know what versions I am running?
In case it’s the latter:
Studio is 22.10.4
Orchestrator Host is 2022.10.2
Edge is 112.0.1722.58 with Extension 22.10.6
Chrome is 112.0.5615.138 with Extension 22.10.6
Furthermore I tried running the process in question in unattended mode and this appears to work, so that’s a relieve already. It only seems to affect Debugging in Studio.
I’ll try to get a colleague to try to see if this is a “Me-Issue”
Thank you for your input. I tried your suggestion. Results in “Reference Error: DoLogOut() is not defined”.
Again: I did pay attention to the selectors. In this case the surrounding Attach Browser targets msedge.exe and the inject js activity targets the top level html element of the page.
It seems to depend on the Project (so dependencies or other project specific settings I guess).
"function() {window.location.assign(""javascript:.."");}"
this works if I put this in a new XAML in the (older) Project I succesfully tested unattended earlier (see my post further up).
So its not the Studio Version, Browser, Extension and it’s not different behaviour between debugging/unattended either.
The very same code does not work in a fresh Project. I’ll try to figure out the differences.