Unable to break the jython for loop

220 Views Asked by At

I am trying to automate component identification using Jython script. The problem is I am unable to stop the iteration once the matching value is reached. The code is:

def GetAll(Dialog):
    ChildItems=Dialog.getComponents()
    for item in ChildItems:
        GetAll(item)
        rc.logMessage(str(item.getName()))
        if(str(item.getClass())==rc.lookup("Class")):
            if (str(item.getName())==rc.lookup("TextOnButton")):
                item.doClick()
                rc.setLocal("Clicked", True)
                break

I am unable to break the for loop despite putting the break statement.

1

There are 1 best solutions below

0
On
def GetAll(Dialog):
    ChildItems=Dialog.getComponents()
    for item in ChildItems:
        rc.logMessage(str(item.getName()))
        if(str(item.getClass())==rc.lookup("Class")):
            if (str(item.getName())==rc.lookup("TextOnButton")):
                item.doClick()
                rc.setLocal("Clicked", True)
                break
    GetAll(item)

This should work. Need to check make a parameter for what type of property you are looking for. This may work only for the items that may have property as above.