Getting IndexError while trying to reach element in combo box, where the first element is empty (absent)
See original GitHub issueExpected Behavior
Test should be able to select element in combo box, where the first element is not present (absent) by default

Actual Behavior
Attempt to reach element in the combo box with first element absent gives the error.
Steps to Reproduce the Problem
- Emulate combo box with several elements, the first element selected by default should be empty (absent)
- 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to deleselect / blank a databound ComboBox ...
Try to set the [ComboBoxObj].SelectedIndex=-1; which will make it to empty value. -1 refers to deselect or nullify the value of combobox.
Read more >Understanding the Python Traceback
In this step-by-step tutorial, you'll learn how to read and understand the information you can get from a Python traceback. You'll walk through...
Read more >3. Strings, lists, and tuples — Beginning Python Programming ...
It causes the runtime error IndexError: list index out of range . The reason is that len(seq) returns the number of elements in...
Read more >List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when you try and access an item using a value that is out...
Read more >List - OutSystems 11 Documentation
By default a list is empty, meaning that it has no elements. ... When you are iterating the first element, this property is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

WinForms. This is reproducible in MaterialDesign WPF demo app has this issue as well. Very similar to #916
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 theuiabackend.