1

I want to access text values from a List BOX (pywinauto uia wrapper)that is nested inside LIST view inside the application used.

code snippet:

#upper window
up_window.ListView.wait('visible').Select('Enforcement').click_input(double=True)
time.sleep(5)
#after this enforcement window opens and i need to select the third tab which is performed below and its working fine.

enfwin = guilib.get_window('Enforcement', backend='uia') 
# guilib is user defined library which will retun the window handle

if enf_win.TabControl.get_selected_tab() != 2:        
    log.debug("Clicking on 'Targets' tab in Enforcement window")
    enf_win.TabControl`enter code here`.wait('enabled', timeout=60).select(2)

time.sleep(30)
list_rows = enf_win.ListBox.wait('ready', timeout=60).texts()

dcs_win.ListView.wait('visible').Select('Enforcement').click_input(double=True)
time.sleep(5)
enf_win = guilib.get_window('Enforcement', backend='uia')

if enf_win.TabControl.get_selected_tab() != 2:        
    log.debug("Clicking on 'Targets' tab in Enforcement window")
    enf_win.TabControl.wait('enabled', timeout=60).select(2)

time.sleep(30)
list_rows = enf_win.ListBox.wait('ready', timeout=60).texts()

The problem here is, when I am calling this function two times from script, 1 st run its fetching the list_rows whereas in second run its returning blank. It seems like it needed some time in between. But increasing time is not helping.

Please suggest if any modification I need to do to fetch list box value each time.

kalehmann
  • 4,821
  • 6
  • 26
  • 36
user3664681
  • 171
  • 1
  • 3
  • 13
  • What kind of application do you automate? WinForms? – Vasily Ryabov Apr 03 '19 at 15:08
  • 1
    Yes, its WinForms – user3664681 Apr 04 '19 at 05:14
  • Hi again. We've tried to reproduce it on synthetic case (test app) and all time it returns correct list of rows. Please make sure `enf_win.ListBox.wait('ready', timeout=60).draw_outline()` draws a bound around correct list box. In theory it's possible it was matched to different elements at different moments. – Vasily Ryabov Nov 22 '20 at 12:41

0 Answers0