0

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.

DavidG
  • 24,279
  • 14
  • 89
  • 82
  • This is much easier via generic components - see: https://www.qfs.de/en/qf-test-manual/lc/manual-en-bp_componentrecognition.html#sec_bpCRGeneric (you don't need to write any jython code here ...) – quant Nov 07 '17 at 19:56

1 Answers1

1
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.

Farhad
  • 4,119
  • 8
  • 43
  • 66