Forum Discussion

TrevorM's avatar
TrevorM
Occasional Contributor
3 years ago

Clipboard checkpoint anomaly

I am having a problem using the Clipboard checkpoint. I have tried both the Equals to and Contains options.

The text Cashbook (14 items) has been copied to the clipboard. When I try to create a checkpoint as below, this fails.

 

function test()
{
if(aqString.StrMatches("Cashbook (14 items)", NameMapping.Sys.Clipboard) == true)
Log.Checkpoint("The clipboard checkpoint succeeded.");
else
Log.Error("Clipboard checkpoint failed");
}

 

If I change "Cashbook (14 items)" to either "Cashbook" or "(14 items)", the checkpoint passes - it only fails with "Cashbook (14 items)"

I tried escaping the brackets, but that doesn't work either (removed the brackets from both the test and the clipboard, and that's OK)

 

NOTE: This is a subset of a much bigger clipboard, but this seems to be the problem area (there are a lot of other bracketed items in the real test)

  • Hi TrevorM ,

     

    I think TestComplete is parsing the backslash/escape character prior to passing it to the function, so the parenthesis are being treated as a special character rather then a literal.  Using a double backslash should work...something like this:

     

    if (aqString.StrMatches("Cashbook \\(14 items\\)", NameMapping.Sys.Clipboard) == true)

     

    I hope this helps.

  • Hi TrevorM ,

     

    I think TestComplete is parsing the backslash/escape character prior to passing it to the function, so the parenthesis are being treated as a special character rather then a literal.  Using a double backslash should work...something like this:

     

    if (aqString.StrMatches("Cashbook \\(14 items\\)", NameMapping.Sys.Clipboard) == true)

     

    I hope this helps.

  • sonya_m's avatar
    sonya_m
    SmartBear Alumni (Retired)

    Thank you for the suggestion, Chris!

     

    Hi TrevorM, please let the Community know if this helps.