How to use _get_sub_menu_handle method in pyatom

Best Python code snippet using pyatom_python

utils.py

Source:utils.py Github

copy

Full Screen

...647 # Above one looks for menubar item648 # Following looks for menuitem inside the window649 menu_handle_list=window_handle.findAllR(AXRole="AXMenu")650 for menu_handle in menu_handle_list:651 sub_menu_handle=self._get_sub_menu_handle(menu_handle, object_name)652 if sub_menu_handle:653 return sub_menu_handle654 raise LdtpServerException("Unable to find menu %s" % object_name)655 def _get_sub_menu_handle(self, children, menu):656 strip=r"( |:|\.|_|\n)"657 tmp_menu=fnmatch.translate(menu)658 stripped_menu=fnmatch.translate(re.sub(strip, u"", menu))659 for current_menu in children.AXChildren:660 role, label=self._ldtpize_accessible(current_menu)661 if re.match(tmp_menu, label) or \662 re.match(tmp_menu, u"%s%s" % (role, label)) or \663 re.match(stripped_menu, label) or \664 re.match(stripped_menu, u"%s%s" % (role, label)):665 return current_menu666 raise LdtpServerException("Unable to find menu %s" % menu)667 def _internal_menu_handler(self, menu_handle, menu_list,668 perform_action = False):669 if not menu_handle or not menu_list:670 raise LdtpServerException("Unable to find menu %s" % [0])671 for menu in menu_list:672 # Get AXMenu673 if not menu_handle.AXChildren:674 try:675 # Noticed this issue, on clicking Skype676 # menu in notification area677 menu_handle.Press()678 except atomac._a11y.ErrorCannotComplete:679 if self._ldtp_debug:680 print(traceback.format_exc())681 if self._ldtp_debug_file:682 with open(self._ldtp_debug_file, "a") as fp:683 fp.write(traceback.format_exc())684 # For some reason, on accessing the lenght first685 # doesn't crash, else686 """687 Traceback (most recent call last):688 File "build/bdist.macosx-10.8-intel/egg/atomac/ldtpd/utils.py", line 178, in _dispatch689 return getattr(self, method)(*args)690 File "build/bdist.macosx-10.8-intel/egg/atomac/ldtpd/menu.py", line 63, in selectmenuitem691 menu_handle=self._get_menu_handle(window_name, object_name)692 File "build/bdist.macosx-10.8-intel/egg/atomac/ldtpd/menu.py", line 47, in _get_menu_handle693 return self._internal_menu_handler(menu_handle, menu_list[1:])694 File "build/bdist.macosx-10.8-intel/egg/atomac/ldtpd/utils.py", line 703, in _internal_menu_handler695 children=menu_handle.AXChildren[0]696 IndexError: list index out of range697 """698 len(menu_handle.AXChildren)699 # Now with above line, everything works fine700 # on doing selectmenuitem('appSystemUIServer', 'mnu0;Open Display*')701 children=menu_handle.AXChildren[0]702 if not children:703 raise LdtpServerException("Unable to find menu %s" % menu)704 menu_handle=self._get_sub_menu_handle(children, menu)705 # Don't perform action on last item706 if perform_action and menu_list[-1] != menu:707 if not menu_handle.AXEnabled:708 # click back on combo box709 menu_handle.Cancel()710 raise LdtpServerException("Object %s state disabled" % \711 menu)712 # Click current menuitem, required for combo box713 menu_handle.Press()714 # Required for menuitem to appear in accessibility list715 self.wait(1) 716 if not menu_handle:717 raise LdtpServerException("Unable to find menu %s" % menu)718 return menu_handle...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful