Forum Discussion

DavidE's avatar
DavidE
Contributor
6 years ago
Solved

Log Message and Code Expressions

I am attempting to post a log message in a keyword test that has both static text as well as a variable.  It seemed simple enough.

 

I figured from within the Log Message, I would choose "Code Expression" and type something like this:

 

"Results: " + KeywordTests.TestNameVariables.VariableName

 

However when the test runs, the lines for the log message are completely blank.  Removing the static text "Results: " from the beginning of the code expression, does yield the value of the variable, but I want to put some qualifier on it explaining what the value of that variable is in the report.

 

Thoughts?

  • It's possible that the syntax for concatenation of strings that you have printed is not proper syntax for the code language selected for your test project.  I believe VBScript uses a different concatenation syntax.

    The other possibility has to do with the fact that script languages are not strongly typed.  So, if the variable is an object and you're trying to concatenate it as a string, behavior is unpredictable.  Or if it's a number. Or something like that.  Double check the variable data type.  If it's not set to string you might want to explicitly convert

     

    "Results: " + aqConvert.VarToStr(KeywordTests.TestNameVariables.VariableName)

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    It's possible that the syntax for concatenation of strings that you have printed is not proper syntax for the code language selected for your test project.  I believe VBScript uses a different concatenation syntax.

    The other possibility has to do with the fact that script languages are not strongly typed.  So, if the variable is an object and you're trying to concatenate it as a string, behavior is unpredictable.  Or if it's a number. Or something like that.  Double check the variable data type.  If it's not set to string you might want to explicitly convert

     

    "Results: " + aqConvert.VarToStr(KeywordTests.TestNameVariables.VariableName)
    • DavidE's avatar
      DavidE
      Contributor
      That did it! Thanks for the help! Didn't consider the possibility that it was an object rather than a string.