Grab a variable out of ExecuteJS
-
Hello,
How can i grab a variable from ExecuteJS block
and re-use as variable in loliscript
for ex:
after navigating to example.com
i tried EXECUTEJS "var store = JSON.stringify(ObjectX)"
PRINT "<store>"Regards
GunGrave
-
Hello!
You can't.
The only way to grab it is to generate an element and add it to the DOM (through the ExecuteJS block) and set your data as an attribute of that element, so you can then retrieve it with an ElementAction block.
-
there is also the was to document.write(whatiwanttograb) or document.cookie += whatiwanttograb
another question/request
working with selenium outside of OB, i was able to executejs and return the value and save it to a variable
i already did this many time with python + seleniumso dont you think it is a thing that can be added to ob, since it is already on selenium
thank you
best regards
-
Yes sure it can be added, just open an issue on github and maybe provide some piece of code (even in another language) ^_^ I was just answering that you can't do that in the current version of OB, not that it cannot be done at all!
-
piece of code sent as message box.
and i will write the request in github nowthanks
-
Hello @Ruri,
can you add also a way to pass on a variable to EXECUTEJS
for example to pass on the USER or PASS
thank you
best regards
-
EXECUTEJS will replace any variable in the script using the usual syntax before actually executing it, so you can type for example
EXECUTEJS "console.log('<MYVAR>');"
and it will work
-
yeah, it was my mistake