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

Application.window and findwindows.find_elements can accept keys specified in *ElementInfo.renamed_props #1342

Open
wants to merge 1 commit into
base: atspi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion pywinauto/findwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def find_elements(**kwargs):
# tell user about new property name for every renamed one
if hasattr(backend_obj.element_info_class, 'renamed_props'):
#renamed_erros = []
for key, value in kwargs.items():
items = list(kwargs.items())
for key, value in items:
renamed_prop = backend_obj.element_info_class.renamed_props.get(key, None)
if renamed_prop is not None:
new_key, values_map = renamed_prop
Expand Down
24 changes: 14 additions & 10 deletions pywinauto/unittests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,21 +647,25 @@ def test_window(self):

self.assertRaises(ValueError, app.windows_, **{'backend' : 'uia'})

title = app.window(name="Untitled - Notepad")
title_re = app.window(name_re="Untitled[ -]+Notepad")
name = app.window(name="Untitled - Notepad")
name_re = app.window(name_re="Untitled[ -]+Notepad")
title = app.window(title="Untitled - Notepad")
title_re = app.window(title_re="Untitled[ -]+Notepad")
classname = app.window(class_name="Notepad")
classname_re = app.window(class_name_re="Not..ad")
handle = app.window(handle=title.handle)
handle = app.window(handle=name.handle)
bestmatch = app.window(best_match="Untiotled Notepad")

self.assertNotEqual(title.handle, None)
self.assertNotEqual(title.handle, 0)
self.assertNotEqual(name.handle, None)
self.assertNotEqual(name.handle, 0)

self.assertEqual(title.handle, title_re.handle)
self.assertEqual(title.handle, classname.handle)
self.assertEqual(title.handle, classname_re.handle)
self.assertEqual(title.handle, handle.handle)
self.assertEqual(title.handle, bestmatch.handle)
self.assertEqual(name.handle, name_re.handle)
self.assertEqual(name.handle, title.handle)
self.assertEqual(name.handle, title_re.handle)
self.assertEqual(name.handle, classname.handle)
self.assertEqual(name.handle, classname_re.handle)
self.assertEqual(name.handle, handle.handle)
self.assertEqual(name.handle, bestmatch.handle)

app.UntitledNotepad.menu_select("File->Exit")

Expand Down