Another JS Inject Question related to Angular elements

This is another post related to my original post here:

I think I probably know the answer to this question already but figured I’d ask. So the method described in my previous post works great for angular elements as long as the elements within this line are physically defined:

var grid = angular.element('.slickGridDimensionsWithFilter').scope().d.gridOptions.grid;

Where it fails I have found this week is when the individual that did the angular coding (using Slickgrid) in this cases uses a different approach to doing the same thing on a different page. What I found is to get to the Slickgrid I need on another page the above line now looks like this:

var grid = angular.element('#unplacedAdUnitsViewerView\\.grid').scope().prototype.gridOptions.grid;

Note the use of “.prototype.” vs “.d.”. On the former “var grid” example above and for that web page, “d” physically exists and is found/seen within the scope() structure for angular.element(‘.slickGridDimensionsWithFilter’).scope() when using the Chrome console. “d” and a number of other physically defined elements exist as well. The injected JS has access to that d elements and its children and so on so the JS Inject works great.

On this new page I’m looking at, the method I got working before does not work for where its Slickgrid is stored because of the “.protoype.” below:

var grid = angular.element('#unplacedAdUnitsViewerView\\.grid').scope().prototype.gridOptions.grid;

When I run this through UiPath JS Inject, the chrome console shows this error :frowning:

Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
    at UPAdUnitsUnplReasonsByExceptions (<anonymous>:1:218)
    at <anonymous>:1:1189

Unfortunately, there is literally nothing physical available after the scope() for the above “var grid”:

So the question … is there any magic to get this working ?

I’m not a JS developer and I don’t understand the whole Chrome security side of things for injected JS which I think is where my challenge is coming from.

Granted I can still use Inject JS having JS ignore the whole angular element path (which is so fast when it works !!!) and instead address the HTTP elements themselves checking and scrolling where necessary. I was really hoping to adapt/adopt what I got working on another page to work on this page here :frowning:

I think the ultimately answer to this question is there is no magic here without going deep into Chrome security and all that.

While the Chrome console can see prototypes and $ based elements, I could not find a means of getting injected JS to see these reliability. I did work out how to use Injected JS using “Find Children” and looping over elements and (slightly less looping) using specific Selector addressing.

While working against angular objects with injected JS is possible is it VERY dependent on the angular development of how those elements was done making them available to the injected JS but the hack I got working (for when it does work) makes passing in arguments and getting results back out another challenge I’m not willing to invest the time into.

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