Execute JS and save to variable using AppleScript


I am trying to execute Javascript in Chrome and then save result as KM variable (the same operation as on the first screenshot) using AppleScript, however, no luck. Getting an error:
error "Keyboard Maestro Engine got an error: Can’t make missing value into type text." number -1700 from missing value to text

Could you please assist?


You are not using the proper AppleScript commands for Chrome.
Did you review the Google Chrome dictionary from the Script Editor:


Thanks for your reply. Just tried plenty of combinations but it still gives me different errors.
Actually, this code worked before (screenshot attached) that is why I cannot get where am using using not proper commands.
Since I am trying to pass the variable to KM via AppleScript it is broken.
image (1)

Combinations won't help. You must explicity follow the Chome Dictionary.
You're missing the "tab" object.

You need something like this:

set jsStr to "

tell application "Google Chrome"
  set oTab to active tab of window 1
  set scriptResults to execute oTab javascript jsStr
end tell

return scriptResults
1 Like

Appreciate your help. Thank you!