Ask a Question

Run the Child Test Item hold by a TestItem

SOLVED
Ravik
Super Contributor

Run the Child Test Item hold by a TestItem

Hi,

 

I have added a New Test Item and under that Test Item I have added Child Test Item. 

 

as per the link - https://support.smartbear.com/testcomplete/docs/reference/project-objects/project/testitems/testitem...

https://support.smartbear.com/testcomplete/docs/reference/project-objects/project/testitem/index.htm...

 

Test Organization like -

 

Regression Test Pack -

             Login Test

                      Valid User

                       Invalid User

                New Order

                         Partial Order

                         Complete Order     

 

Here I did not find any method to access Child Test Item , like to access Valid User , Invalid User

 

Below code work - 

 

Set TestItems = Project.TestItems

Set TestItem = TestItems.TestItem(0) 

log.Message TestItem.Name

 

but this not work -

 

Set TestItems = Project.TestItems

Set TestItem = TestItems.TestItem(1) 

log.Message TestItem.Name

 

how can access Test Item along with all childs and child of Childs

4 REPLIES 4
baxatob
Community Hero

Hi,

 

Set TestItem = TestItems.TestItem(0) - returns only the root items. In your case you have only one root item (with index = 0)

 

You need to navigate each node of your tree.

Ravik
Super Contributor

@baxatob How to navigate for each node ?? Is there any method do we have in TC for it.

baxatob
Community Hero

Hi,

 

You can do it using tree recursion. I will provide the code in Python:

 

def get_item_name(node):
    if node.ItemCount > 0:
        for i in range(node.ItemCount):
            Log.Message(node.TestItem[i].Name)
            get_item_name(node.TestItem[i])


def main():
    get_item_name(Project.TestItems)
Ravik
Super Contributor

@baxatob Thanks 🙂

 

its work for me.

cancel
Showing results for 
Search instead for 
Did you mean: