Catchpoint Transaction tests use Selenium variables to store JavaScript data through the storeScriptVariable() command.
The storeScriptVariable() command saves the value returned from executed JavaScript into a Selenium variable. This can be used to create metrics out of the custom performance mark times for a given page. This is available for Transaction tests using the Chrome monitor.
Syntax:
storeScriptVariable(name, script)
Best Practices:
It is recommended that the script called is a single function with a return or a single variable only. If additional JavaScript needs to be injected and executed to initialize the function or variable, it is recommended to use the runScript() command to perform the injection. The storeScriptVariable() should only execute JavaScript functions that have been defined on the page or have been injected with the runScript() command.
Example:
//Open a page to execute JS on
open("http://www.google.com")
//Create a JS function that returns 'point'
runScript("function bar(){return 'point';}")
//Create a variable the concatenates strings and then stores 'catchpoint'
runScript("var foo='catch' + bar();")
//store JS data into Selenium variable (The second parameter cannot be a JS expression)
storeScriptVariable("foobar","foo;")
//call the stored Selenium variable to verify its contents
open(https://www.google.com/?gws_rd=ssl#q=${var(foobar)})
*Note that this value can then be made into an insight using either "setTracepoint" or setIndicator".
setTracepoint(token, ${var(foobar)}) setIndicator(token, ${var(foobar)})