Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

A SilkTest Test Suite cannot pass an argument containing "double quotes", how can this be remedied?

A SilkTest Test Suite cannot pass an argument containing "double quotes", how can this be remedied?

Problem:

A SilkTest Test Suite cannot pass an argument containing "double quotes", how can this be remedied?

Resolution:

QUESTION
----------------------------------

A SilkTest Test Suite cannot pass an argument containing "double quotes", how can this be remedied?

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"


Old KB# 21824

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:24
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.