0

I created a template for my test suite in QTP where the level of abstraction (parameterization) is sufficiently good.

I would now need to populate a new test suite from the existing pattern, thus replacing certain entries with other ones in various files.

For example one of the words I deliberately put in the script suite pattern is [Template], therefore I would need to copy and paste the template with a different name, change all the entries by [Template] to the new string and so forth.

Any code would be appreciated as my VBScript skills are not optimal ;)

Thanks in advance!

Pixie
  • 412
  • 1
  • 8
  • 26

1 Answers1

1

Use this demo script:

Option Explicit

Dim gMap : Set gMap = Createobject("Scripting.Dictionary")

Function replGMap(sM, nPos, sSrc)
  replGMap = gMap(sM)
End Function

Dim reMap : Set reMap = New RegExp
reMap.Global = True
reMap.Pattern = "\[\w+\]"

gMap("[A]") = "abra"
gMap("[B]") = "cadabra"

WScript.Echo reMap.Replace("1[A]2[A]3[B]4[A]5", GetRef("replGMap"))

output:

abra2abra3cadabra4abra5

as a list of keywords to look up in the VBScript Docs. For using a function in .Replace, see here.

The FileSystemObject provides the means (Open/CreateTextFile, ReadAll, Write) to read and write files.

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96