question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
eratheocommented, Apr 22, 2021

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

0reactions
qozlecommented, Mar 3, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found