How to buffer JS Executed return value in Tosca

  • 23 November 2023
  • 3 replies

Userlevel 2

In Tosca there are two native Modules to work with JavaScript:

  1. “Execute JavaScript”
  2. “Verify JavaScript Result”

The first one executes the script


While the second one executes and verifies the returned result 


The question is how to get the result from JS execution and store in the buffer?

For example, I want to take the active tab title by executing this JS command which works in browser console

document.querySelector('html head title').textContent;


Now, how to store the value of that command in the buffer?


Best answer by brendon.russell 3 December 2023, 23:03

View original

3 replies

Userlevel 2

Two things to get this to work:
1. Add “return “ at the beginning of the JavaScript as shown in the manual for the Verify Javascript module, i.e.

return document.querySelector('html head title').textContent;

(Note that in your example here this simpler version should also work:
return document.title;)

  1. Use {XB[Your Buffer Name]} in the Result to save the entire output into a buffer. (This is a workaround with the Verify action mode since for some reason the module has been built in such a way that it doesn’t directly support the Buffer action mode.)
Userlevel 2

Hi Nissyan,

Please find the below example for the same.


Harish n

Userlevel 2

Thank you both 👍👍 for your answers.

So there was a trick which was not obvious from the module description.