Forum Discussion

guido_riedweg's avatar
guido_riedweg
New Contributor
10 years ago

Replace Runner.CallMethod in Code Expression

Hi,

I want to concat two strings in a code expression and assign the value to a variable. One string is a constant, while the other string is the result of a script method. I achieved this by using the operation Set Variable Value, setting Mode to Code Expression and setting Value to aqString.Concat("MyString_", Runner.CallMethod("Unit1.getUniqueString")).



This works fine, but the documentation for Runner.CallMethod says that this method is obsolete. Is also says that the method should be called directly instead. I've tried to rewrite Value to aqString.Concat("MyString_", Unit1.getUniqueString), but this does not work (the variable value will be completely empty).



How can i call a script method from a code expression, without using Runner.CallMethod?



Best regards

Guido

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Guido,



    a) You may still use Runner.CallMethod() even despite the fact that it is obsolete - there are a lot of obsolete methods in TestComplete that are supported for years (and I love this, thanks to SmartBear);



    b) Depending on the script language of your project you may try to use either eval() or evaluate() functions: aqString.Concat("MyString_", eval("Unit1.getUniqueString")).