I am attempting to create a VBScript function (within the context of QuickTest Pro 10) that is able to take in a line of code as a parameter, such as: JavaWindow("Export Control Notice").JavaButton("OK").Click
Problem is, when I try passing that line as a string, VBScript understandably chokes on the quotes. Here is the catch: I have many lines of code similar to the one above, so I would like to take the line of code and pass it as is. I don’t want to go around doubling the quotes for these lines of code, let along for every new line that QTP records. (Find/Replace All can easily go out of control)
How can I pass the above line of code?
If turning it into a string is the way to go, how can I encode that line so VBscript doesn’t choke on the quote marks?
Additionally, I haven’t been able to find any way to change the delimiter to something other than quote marks to assign the line of code as a string. Finding a way to change the delimiter would probably solve this issue.
Alternately, I’ve also tried passing JavaWindow("Export Control Notice").JavaButton("OK") as an object into the function and that has worked. Unfortunately, there doesn’t seem to be a way to turn that object back into a string in order to append ".Click" (or some other action stored as a string) back onto the end of it. Am I overlooking something?
Depending on how exactly you ‘have’ those lines of code (in your head, in a text document, …) and whether you prefer to type or to program you can
put them into VBScript code using the proper escape (“”):
put them into VBScript code using a delimiter of your choice and Replace():
put them in an external file (.txt, .xls, .xml, …) (resp. use the given document); load and parse the file into a suitable data structure (array, dictionary, …). Use that collection to feed your function.