Answered question

How can I replace some string from a value using a javascript?

I am stuck with the design of my scenario. I have a dynamic parameter that I can extract from a previous response of the server. However, the value that should be re-used is not exactly the same. I have to replace some characters. I know that it can probably done through javascript but I don't have the skill to do that. Could you help me?

When you have to handle dynamics parameters, you will have to extract values from server response.

Unfortunately, you may have to alter the extracted value so it can be re-used in a sub-sequent request. If you need to replace some characters, it can be done through a Neoload javascript.


Here is an example:


var extracted = "8A0ewTO\x2fwnduvf\x2fWNtcB9eHNUZs3Z2sV42OBRaEs";

var modified = extracted.replace(/\x2f/g,"/"); // it will replace "\x2f" by "/"

logger.debug("my modified value is =" +modified);


This javascript will replace all the occurrences of "\x2f" by "/". It is using a regular expression to perform that otherwise it will only replace the first occurrence.


For more information, see "NeoLoad Javascript API" in Neoload documentation.

Did you find this useful ?

No (0)

Yes (2)


100% of users found this answer useful