pywinauto icon indicating copy to clipboard operation
pywinauto copied to clipboard

Getting IndexError while trying to reach element in combo box, where the first element is empty (absent)

Open OlehYermolenko opened this issue 6 years ago • 6 comments

Expected Behavior

Test should be able to select element in combo box, where the first element is not present (absent) by default

gitter_combo

Actual Behavior

Attempt to reach element in the combo box with first element absent gives the error.

Steps to Reproduce the Problem

  1. Emulate combo box with several elements, the first element selected by default should be empty (absent)
  2. Write the test to reach one of the elements in this combo box (not the first one)

Short Example of Code to Demonstrate the Problem

studio_window.well_diagram_combobox.select('5pipes')

Traceback (most recent call last):
  File "C:\Python\Python38\lib\site-packages\pywinauto\controls\uia_controls.py", line 238, in select
    self._select(item)
  File "C:\Python\Python38\lib\site-packages\pywinauto\controls\uiawrapper.py", line 678, in _select
    raise IndexError("item '{0}' not found".format(item))
IndexError: item '5pipes' not found

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<ipython-input-189-2dc54ad1ea74>", line 1, in <module>
    runfile('C:/Python/Projects/automation/index__.py', wdir='C:/Python/Projects/automation')
  File "C:\Python\Python38\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)
  File "C:\Python\Python38\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
  File "C:/Python/Projects/automation/index__.py", line 19, in <module>
    studio_window.well_diagram_combobox.select('5pipes')
  File "C:\Python\Python38\lib\site-packages\pywinauto\controls\uia_controls.py", line 263, in select
    raise IndexError("item '{0}' not found or can't be accessed".format(item))
IndexError: item '5pipes' not found or can't be accessed

Specifications

  • Pywinauto version: 0.6.8
  • Python version and bitness: 3.8.2 x64
  • Platform and OS: Windows 10 x64

OlehYermolenko avatar Mar 02 '20 18:03 OlehYermolenko

Observed the same issue even when first item is no blank. I have same specification as mentioned

pallavi422009 avatar Aug 11 '20 15:08 pallavi422009

I am facing the same issue. Any work around?

deepeshbaid avatar Mar 01 '21 21:03 deepeshbaid

It sounds the same as issue #876. Can someone try the fix from PR #1047 ?

vasily-v-ryabov avatar Apr 17 '21 15:04 vasily-v-ryabov

Also any information on type of application (Qt5, UWP, WinForms?) would be very helpful.

vasily-v-ryabov avatar Apr 17 '21 15:04 vasily-v-ryabov

Also any information on type of application (Qt5, UWP, WinForms?) would be very helpful.

WinForms. This is reproducible in MaterialDesign WPF demo app has this issue as well. Very similar to #916

OlehYermolenko avatar Apr 22 '21 04:04 OlehYermolenko

For anyone reading this looking for a solution- one workaround is to use the type_keys() method to send '{DOWN}' or '{UP}' to navigate to the item you want to select. I'm doing this using the uia backend.

qozle avatar Mar 03 '22 17:03 qozle