NOTICE: Our Community is moving. Get more information. Updated information on a New Login Process
A SilkTest Test Suite cannot pass an argument containing "double quotes", how can this be remedied?
QUESTION ----------------------------------
ANSWER ----------------------------------
A SilkTest Test Suite file cannot pass an argument which contains "double quotes". The double quotes will be stripped from the argument during the exchange.
Passing in "C" to a script will result in the incorrect argument C being used by the testcase.
The following testcase and function, should help to resolve the issue. As the Suite will not allow double quotes to be passed, two single quotes " " are passed instead to the testcase ProcessArgs() , where the ConvertDblAposToQuote() function is called and will convert each of the two single quotes into a double quote on the script side.
Passing in " "C" " to the function below will result in the correct argument "C" being used by the testcase.
Contents of testsuite : example.s
example.t a b ""C""
Contents of testscript : example.t
[-] testcase ProcessArgs ( ) appstate none [ ] BOOLEAN bCheck = TRUE [ ] STRING s [ ] LIST OF STRING lsArgs [ ] lsArgs = GetArgs ( ) [ ] ListPrint (lsArgs) [-] for each s in lsArgs [ ] bCheck = TRUE [-] while bCheck [ ] bCheck = ConvertDblAposToQuote (s) [ ] print (s) [-] BOOLEAN ConvertDblAposToQuote (inout STRING s) [ ] STRING s1 [ ] INTEGER iPos = StrPos ("""",s) [-] if (iPos >0) [-] switch iPos [-] case 1 [ ] s1 = """" + SubStr (s,iPos+2) [-] default [ ] s1 = SubStr (s,1,iPos-1) + """" + SubStr (s,iPos+2) [ ] s=s1 [ ] return TRUE [-] else [ ] return FALSE
Results :
[-] Script example.t (a, b, ""C"") - Passed [-] Testcase ProcessArgs - Passed [ ] a [ ] b [ ] ""C"" [ ] a [ ] b [ ] "C"