Execute a JavaScript in browser shows no results

Hi there! I'm a relative novice with KM, but I've been trying to get more in the weeds here and am having an issue executing a JavaScript in Chrome from KM. When I run the macro with JS in browser action, nothing changes in the console, and the result doesn't save to a variable. Here's the JS I'm using:

var dealWebsite = document.querySelector('[data-test="03cc4c818dcd37ec3f9b8380ef88ad444fecfda7-label"]');

var dealWebsite = dealWebsite.innerText;

and here's the macro in question:

I've checked to make sure "Allow JavaScript from Apple Events" is enabled, restarted Chrome, KM Engine and my computer and saw no difference. I also tried changing the action to display the results in a window, and nothing happens there either (no window pops up, and no change in the console). I've also tested the code in the Chrome JS console and it returns exactly the result I'm looking for

Does anyone have any suggestions/experience for troubleshooting this?

Hey Joe,

You're not actually returning anything...

Try this:

(() => {

   const dealWebsite = document.querySelector('[data-test="03cc4c818dcd37ec3f9b8380ef88ad444fecfda7-label"]');
   const textResult = dealWebsite.innerText;
   return textResult



1 Like

Hey Chris, that solved it exactly! I didn't mention it, but also a novice with JavaScript :sweat_smile: Thank you so much!