Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in calling UIAElementInfo.descendants with depth and criteria like control_type arguments #1336

Open
junkmd opened this issue Sep 20, 2023 · 0 comments · May be fixed by #1337
Open
Assignees

Comments

@junkmd
Copy link
Contributor

junkmd commented Sep 20, 2023

While working on #1334, I had questions about the implementation of UIAElementInfo.descendants, so I conducted an investigation.

Expected Behavior

The following tests I added in pywinauto/unittests/test_uia_element_info.py should be passing. These tests passed when I added them while checking out 0.6.8.

# ...
# if UIA_support:
#     class UIAElementInfoTests(unittest.TestCase):
        # ...
        def test_default_depth_with_criteria_descendants(self):
            # There is no element with `control_type='Slider'` in children of the dialog.
            self.assertGreater(len(self.ctrl.descendants(control_type="Slider")), len(self.ctrl.children(control_type="Slider")))

        def test_depth_level_one_with_criteria_descendants(self):
            self.assertEqual(self.ctrl.children(control_type="ToolBar"), self.ctrl.descendants(control_type="ToolBar", depth=1))
            self.assertEqual(self.ctrl.children(control_type="Button"), self.ctrl.descendants(control_type="Button", depth=1))

        def test_depth_level_three_with_criteria_descendants(self):
            slider = next(iter(self.ctrl.descendants(control_type="Slider", depth=3)), None)
            self.assertIsNotNone(slider)
            self.assertIn(slider, self.ctrl.descendants(depth=3))
        # ...

Actual Behavior

Adding the above-mentioned tests to the current atspi branch(bf7f789) does not result in them passing.

======================================================================
FAIL: test_depth_level_three_with_criteria_descendants (pywinauto.unittests.test_uia_element_info.UIAElementInfoTests.test_depth_level_three_with_criteria_descendants)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "...\pywinauto\pywinauto\unittests\test_uia_element_info.py", line 131, in test_depth_level_three_with_criteria_descendants
    self.assertIsNotNone(slider)
AssertionError: unexpectedly None

Steps to Reproduce the Problem

Please see above.

Short Example of Code to Demonstrate the Problem

Please see above.

Specifications

  • Pywinauto version: the current atspi branch(bf7f789)
  • Python version and bitness: Python 3.11.4 64bit
  • Platform and OS: Windows10 64-bit

Appendix

iter_descendants still has an issue where it doesn't produce the same results as descendants when it took criteria args, even as of version 0.6.8. I plan to address this after #1334 is merged.

@junkmd junkmd self-assigned this Sep 20, 2023
junkmd added a commit to junkmd/pywinauto that referenced this issue Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant