Ask a Question

Get script function name in Python

markre94
Occasional Contributor

Get script function name in Python

Hi,

I have a trouble with obtaining the name of the test function while running it as a Script Routine using Python.

 

How to retreived test function name via Project.TestItems.Current.ElementToBeRun.Caption or something else when the script is not running from ExecutionPlan as a test item but as Script Routine from the code.

3 REPLIES 3
Marsha_R
Community Hero

You should just be able to assign  Project.TestItems.Current.ElementToBeRun.Caption  to a variable. What happens when you try that?

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
markre94
Occasional Contributor

Hi @Marsha_R  that works as expected but I would like to run my script directly from the Test Complete code editor and still have the same effect. I did't manage to figure it out if this is even possible.

 

I have a defined python function that is added as a TestCase in the Execution Plan. What I want is to retireve the name of that function so the value that I should get with Project.TestItems.Current.ElementToBeRun.Caption both when running it from Execution Plan and when running it directy from code editor.

 

I understand what you're trying to do, but sometimes troubleshooting takes going back to basics to figure out what's working and what's not!

 

In your case, this is working as expected. ElementToBeRun only applies in the Execution Plan. What you may want to use instead is CurrentTestCase because that works in many places.

 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqtestcase/currenttestcase...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
cancel
Showing results for 
Search instead for 
Did you mean: