The error I get running something like above is:
(Worth noting that my variable is dynamically generated unlike example code above)
this is what you want:
Explanation: JS alert method takes String as a parameter, so it must be enclosed in quotes.
BUT - if you want to pass variable from Katalon, you must go out from String and use + sign to concat variable to the rest of JS string.
Plain myJs value (after all replacements) is then **alert(“sometext”)
**To prevent confusion of escaping doublequotes in myJs variable, you can use singlequotes for defining String in Katalon, like this:
String myJs = 'alert("' + myvariable + '")'