Executing JavaScript using selector with a colon

I'm trying to read values from a web page using the "Execute a JavaScript in Safari" actions. This mostly works very well.

But some of the values are identified with id's that have embedded colons. Ex.


I know I have to escape the colons so my js to retrieve what I need, (that works in the browser's console), is:


But my KM action (to save the value in a variable) returns nothing. I've tried varying numbers of backslashes to see if I needed to "escape the escape", so to speak, but no luck with any of it.

Any ideas?

Thanks in advance.

Hi and welcome,
Can you share what you have so far, and the URL or an example

Well, bugger me, it's working now. I swear I tried this already but anyway, I created a new action:

Execute JavaScript in Safari
Save trimmed results without errors to variable “RunAmount”.
Stop macro and notify on failure.

Now my variable has a value.

I can't share the URL since it's private but here's a snippet of the page:


So, problem solved I guess. :smiley:



Hey @Swimszoots - you’re learning fast! Especially the part about when @hello asks he expects results :wink:

1 Like