common, namespace, replace, substring, substr, string, str, scriptless, script-less, scripted, step, view, stepview
Method Zap.Common.ReplaceSubString
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string
Watch this video to learn how to use this method
Have a problem with playback?
In this video we will review ZAP Utility tool item. ZAP Utility provides easy access to various internal ZAPTEST methods and objects. To use it I just need to drag ZAP Utility item from the toolbox to the desired spot in my test workflow. ZAP Utility icon expands list which includes all its objects and methods. Navigating to an item in the list displays relevant tooltip with detailed information. Depending on a method selected, there can be different set of parameters. I will select StringConcatenate method as an example. This step has two required arguments which are depicted by pink color. To access all remaining arguments I need to click expand button. There are two more optional arguments in this step. Each parameter has it's own tooltip describing its purpose and data type. For String or Integer arguments, I can type their values directly in the fields. If the method returns any value, I need to use Output parameter field to specify name for an output variable. Instead of hardcoded argument values I can use Datatable parameters or another variables. To do this I can simply drag the Parameter name from the Datatable..., Or I can drag it from the Variable or Datatable Parameters listbox... Alternatevely I can click the Parameters link, and use the dialog to specify the parameter's type, name, of define a new parameter.
Usage
Function Zap.Common.ReplaceSubString (
String Str,
String OldValue,
String NewValue
)
Parameters
OldValue
String
The string to be replaced
NewValue
String
The string to replace all occurrences of oldValue
Returns
A string that is equivalent to the current string except that all instances of oldValue are replaced with newValue. If oldValue is not found in the current instance, the method returns the current instance unchanged
Example
newString = Zap.Common.ReplaceSubString("oldString", "old", "new")
var newString = Zap.Common.ReplaceSubString("oldString", "old", "new");
Comment
Replace "old" substrings to "new" and save it to variable parameter