Forum Discussion
Dmitry_Nikolaev
15 years agoStaff
Hello Steve,
As far as I understand, you want to get the name of the routine that is currently running. There's no built-in functionality to do this. However, you can do this by using native JScript mechanisms. Here's the getStack function that returns the routine name by using the current call stack:
BTW, when using the Log.Error method, TestComplete posts call stack information on the Call Stack page of the test log. You can find more information in the Log.Error help topic.
As far as I understand, you want to get the name of the routine that is currently running. There's no built-in functionality to do this. However, you can do this by using native JScript mechanisms. Here's the getStack function that returns the routine name by using the current call stack:
function test1()
{
Log.Error("Error X in " + getStack());
}
function getStack()
{
var cur = getStack.caller;
var callers = new Array();
while(cur)
{
callers.push(cur.toString().match(/function (\w*)/)[1]);
cur = cur.caller;
}
return callers.join("\r\n");
}
BTW, when using the Log.Error method, TestComplete posts call stack information on the Call Stack page of the test log. You can find more information in the Log.Error help topic.
Related Content
- 2 years ago
- 2 years ago
Recent Discussions
- 12 hours ago