Depending on how much JS manipulation you need you have 3 options. The first is to use the inbuilt "Browser" plugin, which has a couple of options for evaluating JS. So in this situation you could use the expression Browser.ExecJS("window.testMessage")
to get the value.
If you need to do more then the 3rd party JavaScript plugin is quite popular for this sort of thing. It offers methods for calling JS functions and getting the return value, which is generally safer and faster than executing an arbitrary string like I showed above.
The final option is to write a small plugin using the SDK, this is an advanced use case but might fulfil a few more complex situations that you want. SDK manual