tito / telenium

Automation for Kivy Application
MIT License
67 stars 23 forks source link

select() may generate an identifier that is unusable #23

Open ryan-summers opened 2 years ago

ryan-summers commented 2 years ago

When using the select() function, the provided path cannot necessarily be used for a subsequent select() (or getattr(), etc) and will not properly select any items.

This appears to arise because the XPATH index syntax is slightly different than the path_to syntax use different semantics.

Specifically, the current to_path syntax uses the index of the element in the child widgets list. https://github.com/tito/telenium/blob/52e30bad3025c31749e9bab50a4bc5b62467679e/telenium/mods/telenium_client.py#L107-L114

However, the XPATH syntax uses the index into the list of previously filtered items. This means that if any items are filtered out, the index used by XPATH and the index into the Kivy child list are no longer equivalent.

ryan-summers commented 2 years ago

This becomes problematic whenever the children of a widget have different types. The fix here is to filter the path_to children list to include only children that have the same class as the current widget.

Hubix9 commented 1 year ago

Hi, thanks for posting the idea for a fix! I've noticed that there was no implementation for it and since I needed this feature I went ahead and implemented the fix with addition of a small correction.

Related PR: https://github.com/tito/telenium/pull/27