Forum Discussion

MadGrb's avatar
MadGrb
Contributor
5 years ago

WPFObject() for ListBox without index not working

WPFObject for ListBox without index not working Hi, I have a special listbox. So, I have to work with WPFObject(), but this method doesn't work without an index. Look to my Codes   SelectL...
  • MadGrb's avatar
    5 years ago

    I find a good way, I use find.

    look

    def SelectListBoxItem(ListBox,Contain = ''):
        
            try:
            
                    Delay(Time.OptTimes('Nix'))
                    
                    ListBox.Click()
                    
                    Item = Aliases.JTL_Wawi.Popup.Root.ListBoxEdit
                    
                    SubItem = Item.FindChild('WPFControlText',Contain,1)
                    
                    WaitForAvailablity(Item)
                    
                    if isinstance(Contain, int):
                            if Contain == 0 :
                                    Contain = 1
                                    
                            Item.WPFObject("ListBoxEditItem", '', Contain).Click()
                    elif Contain == '':
                            Item.WPFObject("ListBoxEditItem", Contain,1).Click()
                    else:
                            if SubItem.Exists:
                                    SubItem.Click()
                            else:
                                    Item.WPFObject("ListBoxEditItem","", 1).Click() 
                    
            except Exception as exp:
                    Log.Message('ListBoxEditItem - type:' + str(exp))