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.

For pywinauto.controls.uia_controls.MenuWrapper, the menu_select method throws an AttributeError: 'MenuWrapper' object has no attribute 'visible'

See original GitHub issue

Expected Behavior

No attribute error when calling the menu_select(“menu path”) method on the MenuWrapper class.

Actual Behavior

For pywinauto.controls.uia_controls.MenuWrapper, the menu_select method throws an AttributeError: ‘MenuWrapper’ object has no attribute ‘visible’

Steps to Reproduce the Problem

menu = MenuWrapper(app.ContextMenu.wrapper_object())

menu.menu_select("New->Spread")` 

used the code snippet above to select from right click menu (after the menu was made visible in the application by right-clicking)

Short Example of Code to Demonstrate the Problem

Specifications

  • Pywinauto version: 0.6.8
  • Python version and bitness: Python 3.7 64-bit (Application under test is 64-bit as well)
  • Platform and OS: Windows 10

Output from interactive window

>>> menu = MenuWrapper(app.ContextMenu.wrapper_object())
>>> menu.menu_select("New->Spread")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Aju.jayapalan2\Documents\Beta\px_automation_64\lib\site-packages\pywinauto\controls\uiawrapper.py", line 715, in menu_select
    self.verify_actionable()
  File "C:\Users\Aju.jayapalan2\Documents\Beta\px_automation_64\lib\site-packages\pywinauto\base_wrapper.py", line 680, in verify_actionable
    self.verify_visible()
  File "C:\Users\Aju.jayapalan2\Documents\Beta\px_automation_64\lib\site-packages\pywinauto\base_wrapper.py", line 702, in verify_visible
    if not self.is_visible():
  File "C:\Users\Aju.jayapalan2\Documents\Beta\px_automation_64\lib\site-packages\pywinauto\base_wrapper.py", line 325, in is_visible
    return self.element_info.visible #and self.top_level_parent().element_info.visible
AttributeError: 'MenuWrapper' object has no attribute 'visible'

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ajujayapalcommented, Dec 10, 2019

Hi @ajujayapal it’s wrong usage of MenuWrapper constructor. All wrappers from backend="uia" expect UIAElementInfo object as a constructor parameter. So you have to use this line:

menu = MenuWrapper(app.ContextMenu.wrapper_object().element_info)

Is app.ContextMenu.wrapper_object() returned object of another class than MenuWrapper?

Using your suggestion, I got an AttributeError (on line 721 in menu_select)

For app.ContextMenu.wrapper_object() I got -> <uia_controls.MenuWrapper - ‘Context’, Menu, 3713037277417833081>

Screenshot of the python command line interactive screen. http://bit.ly/35aQ9xH

0reactions
vasily-v-ryabovcommented, Dec 15, 2019

@airelil is right, but more interesting is what menu.children() and menu.descendants() returns. And how it’s compared with what Inspect.exe shows hovering mouse over the menu item (with a hierarchy on screenshot).

Anyway I would say our implementation provided useless error message in this case. I will mark the issue as an enhancement to handle context menus more properly. If menu.children() returns MenuItemWrapper objects, the fix should be pretty easy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pywinauto.controls.uiawrapper - Read the Docs
This class wraps a lot of functionality of underlying UIA features for working with windows. Most of the methods apply to every single...
Read more >
pywinauto Documentation - Read the Docs
How to deal with controls that do not respond as expected (e.g. ... AttributeError: type object '_CustomLogger' has no attribute 'disable'.
Read more >
Cannot Perform MenuSelect with PyWinAuto on Simple VB ...
I am trying to select the "New" Menu item but I receive an error. The error is that there is no Menu. I...
Read more >
How To Get Text That Has No Identifier Inside Pane ... - ADocLib
For pywinauto.controls.uiacontrols.MenuWrapper the menuselect method throws an AttributeError: 'MenuWrapper' object has no attribute 'visible' #862.
Read more >
更新日志 · Pywinauto 中文文档 - 看云
Method scroll() has been added for all UIA controls which have ScrollPattern ... AttributeError: type object '_CustomLogger' has no attribute 'disable'.
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