Forum Discussion
20 Replies
- AlexKaras
Champion Level 1
Hi Daniel,
Eval() does not perform any conversion but takes an input string and passes it to the runtime engine and returns a result. As VBScript is interpreting language, this means that the passed string will be parsed by the runtime engine in the current execution context and executed.
"in the current execution context" means that all components of the string must evaluate to variables, objects, functions, etc. that are available at the point where Eval() is called.
E.g., in order for the
Set obj = Eval("ObjFind(""abcd"", i)")
call to succeed, ObjFind() function must be defined and be accessible, it must return a reference to the object and i variable must be defined. - AlexKaras
Champion Level 1
Hi Bai,
Log.Message("Not found Object " + Object.FullName)
should work... - hao_baiOccasional ContributorThx for you reply, now the log message is "You are trying to call the "FullName" method or property of the "CMDClass" object that does not exist.Not found Object Non-existent object 17:18:37 "
As you can see, Aliases.Sys.processCMD.CMDClass is a name after name-mapping,What I need is to give warning message which contain "Object's name-mapping name" when object not exist.
In a word, how can I convert Object type to string type in Testcomplete7.5 via VB script. - AlexKaras
Champion Level 1
Hi Bai,
All variables in script languages are of OleVariant type (with possible sub-type differentiation as string, integer, etc.). Thus no type conversion in scripting languages is possible.
In your case you should use the WaitAliasChild function (see TC help for more details) and code like this (untested, off top of my head):
If (Aliases.Sys.processCMD.WaitAliasChild("CMDClass", 200).Exists) Then
Log.Message Aliases.Sys.processCMD.CMDClass.FullName
Else
Log.Warning "CMDClass child was not found"
End If
Hi Bai,
When an object is not found during test execution, TestComplete posts the corresponding error to the test log. The Remarks pane for this message should contain the name of the object that is not found. Does not this information enough for you?- hao_baiOccasional Contributor@Alexei
Karas [TeamAQA]/David
AQA, thanks for you reply.
Now I'll tell you the whole story in real scenarios of my test project.
1. I have a function in public script file.
=========public ============
Sub RunModel(key1,key2,key3,Object,str)
Call Run3Key(key1,key2,key3)
If Not Object.Exists Then
Runner.Halt("Run " + CStr(str) + " Failed...")
End If
End Sub
=========public end============
2. In scenario A, I need to press key1/2/3 with "F"/"D"/"U", and check the object
"Aliases.Sys.scenarioA.Toolbar" to confirm whether RunModel OK, So I call:
RunModel("F","D","U",Aliases.Sys.scenarioA.Toolbar,"Aliases.Sys.scenarioA.Toolbar")
3. In scenario B/C/D... I also need to process same case, which key and Object changed. But I don't want to write Log.Warning "scenario B/C/D objectB/C/D" in each case, and I also want to accurate track the log which Object cause the case failed.
Now function RunModel(key1,key2,key3,Object,str) can feed my requirements but not easy to use, if I can convert an Object type to a string directly in TC, the str parameter can ignore. I can use RunModel("F","D","U",Aliases.Sys.scenarioA.Toolbar) directly.
Hi Bai,
You can pass the name of the needed object and evaluate it after that....
RunModel("F","D","U", "Aliases.Sys.scenarioA.Toolbar")
...
Sub RunModel(key1,key2,key3,ObjectName)
Set obj = Eval(ObjectName)
Call Run3Key(key1,key2,key3)
If Not obj.Exists Then
Runner.Halt("Run " & ObjectName & " Failed...")
End If
End Sub- hao_baiOccasional Contributor
Hi Bai,
BTW, you can find documentation on the VBScript language along with the Eval method in the MSDN Library.- hantrung_truongOccasional Contributor
1
2
3
4
5
6
7
8
9
10
...
RunModel(
"F"
,
"D"
,
"U"
,
"Aliases.Sys.scenarioA.Toolbar"
)
...
Sub
RunModel(key1,key2,key3,ObjectName)
Set
obj = Eval(ObjectName)
Call
Run3Key(key1,key2,key3)
If
Not
obj.Exists
Then
Runner.Halt(
"Run "
& ObjectName &
" Failed..."
)
End
If
End
Sub
Hi all,
I have the same question and the above scripts can solve the problem. However, I want to have the parameter as an object instead of string "Aliases.Sys.scenarioA.Toolbar".
But I couldn't find any solution for it. Does anyone can help with this?
Thanks in advance
Trung