The Replace Version Number script code is used as an example of string replacement.
You can copy the code from this page and paste it into the SOASTA CloudTest > Script Editor, or use the following links to download and import the XML for the entire Extract A Session ID Composition or just the Extract A Session ID Script. SOASTA CloudTest XML cn be imported using the Import icon on the toolbar.
// Get the content of the engine.js file returned from the server. var dwrEngineJsMessage = $context.currentClip.getChild('engine.js'); var dwrEngineJsBody = dwrEngineJsMessage.getResponse(msg.RESPONSE_HTTP_BODY); // Extract the scriptSessionId variable from the JavaScript file. // We are looking for a line similar to the following: // (example) // dwr.engine._origScriptSessionId = "E1BA0ED81B186820CE1DD82A7ABAB9DD"; var prefix = 'dwr.engine._origScriptSessionId = "'; var startIndex = dwrEngineJsBody.indexOf(prefix) + prefix.length; var endIndex = dwrEngineJsBody.indexOf('"', startIndex + 1); scriptSessionId = dwrEngineJsBody.substring(startIndex, endIndex); // DWR expects browser to generate a random suffix - // this is copied directly from engine.js (see _getScriptSessionId()). scriptSessionId = scriptSessionId + Math.floor(Math.random() * 1000); // Write the final result to the log for informational purposes. $context.result.postMessage($context.result.LEVEL_INFO, "Extracted scriptSessionId " + scriptSessionId); // Set the clip property. $prop.set("MessageClip", "scriptSessionId", scriptSessionId);