How do i get js object from chrome browser?

For an example, I am having variable say var msg=“Hello World”; in chrome, how can get it to uipath studio? I tried by inject JS activity but no luck.

when i tried using the “debugger” in inject js activity the browser will stop, from there i searched in dev tools i am not able to find my variable.

function abc(){
debugger;
}

1 Like

Hi @vinojash

Are you trying to extract data from chrome browser ? if yes there are inbuilt activities which will perform this action. Please elaborate the scenario bit more.

Regards,
Vijay.

image

Please check the above image, I have an object in chrome browser tab, I have to convert that one as string and display in designer (using writeline or message box activity)

Hey @vinojash

Check this existing thread - Inject JS issue

Regards…!!
Aksh

Hello @aksh1yadav
Hope it an alert message, my question is about getting js object from the browser.

Hi @vinojash

Can you please share the User Interface of site from your browser?

Regards,
Vijay.

Hi @Vijay_Kumar_C, Really i am not using any specific page, but i can reproduce the scenario as follow,

Open this site (https://bay-chess-ai.herokuapp.com/), In console of chrome dev tools type “game”, you can see a game object , just try to stringify and get it back to designer.

@vinojash,

Yes, you can get the value of global variable in debugger mode. Please follow my logic it’s will work for your logic.

  1. As per you’re logic UiPath generated it’s own window is Correct. but we can able get the value from the global level using this code
    " this.window.yourVaraibleName"
  2. Please check the below workflow for more info.

Note: I’m injecting my JS this URL (https://www.google.com/chrome/)

InjectJSInChromeConsole.zip (1.5 MB)

Thanks,
Arunachalam.

@Arunachalam
Yes, you are right, we can access the global variable which we defined inside our script file. but i have to access the global variable which is defined in a web page.
If you watch closely my previous reply, the variable “game” is declared at top level container(actual web page) but our script is executing in another context. so we are not able to access that.

1 Like

@vinojash Did you find an answer? I have exactly the same problem…

Yes @dmarshall ,
I have developed a custom activity to communicate chrome browser using chromedevtoolsprotocol , the example project available in my repository and you can download here . and the custom activity you can download here.

try to understand the flow… I didn’t prepare the readme file yet… :slight_smile: will post soon in my repo.