def setUp(self): """Set some data and ensure the application is in the state we want""" Timings.fast() actionlogger.enable() self.app = Application().start(_notepad_exe()) self.logger = logging.getLogger('pywinauto') self.out = self.logger.handlers[0].stream self.logger.handlers[0].stream = open('test_logging.txt', 'w')
def setUp(self): """Set some data and ensure the application is in the state we want""" Timings.Fast() actionlogger.enable() self.app = Application().start(_notepad_exe()) self.logger = logging.getLogger('pywinauto') self.out = self.logger.parent.handlers[0].stream self.logger.parent.handlers[0].stream = open('test_logging.txt', 'w')
def setUp(self): """Start the application set some data and ensure the application is in the state we want it.""" actionlogger.enable() self.app = Application.start(_notepad_exe()) self.logger = logging.getLogger('pywinauto') self.out = self.logger.parent.handlers[0].stream self.logger.parent.handlers[0].stream = open('test_logging.txt', 'w')
def test_logger_enable_mapped_to_reset_level(self): """Test if the logger enable is mapped to reset_level""" reload_module(actionlogger) # verify on mock self.logger_patcher = mock.patch('pywinauto.actionlogger.ActionLogger', spec=True) mockLogger = self.logger_patcher.start() actionlogger.enable() self.assertTrue(mockLogger.reset_level.called)
def testEnableDisable(self): actionlogger.enable() prev_line_count = self.__lineCount() self.app.UntitledNotepad.type_keys('Test pywinauto logging', with_spaces=True) self.assertEqual(self.__lineCount(), prev_line_count + 1) actionlogger.disable() self.app.UntitledNotepad.menu_select('Help->About Notepad') self.assertEqual(self.__lineCount(), prev_line_count + 1) actionlogger.enable() self.app.window(title='About Notepad').OK.click() self.assertEqual(self.__lineCount(), prev_line_count + 2)
def open(): try: #Creating directory if it don't exist. os.mkdir('.\Log') except: pass #Setting up file log. file = 'Log\\' + datetime.now().strftime('%Y-%m-%d_%H-%M-%S') + '.log' logging.basicConfig( level=logging.NOTSET, format= "%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s", handlers=[logging.FileHandler(file), logging.StreamHandler()]) #Starting a traceback registry for pywinauto actionlogger.enable()
The example shows how to work with MS Paint application. It opens JPEG image and resizes it using "Resize and Skew" dialog. """ from __future__ import print_function import logging from pywinauto import actionlogger from pywinauto import Application import argparse parser = argparse.ArgumentParser() parser.add_argument("--log", help="enable logging", type=str, required=False) args = parser.parse_args() actionlogger.enable() logger = logging.getLogger('pywinauto') if args.log: logger.handlers[0] = logging.FileHandler(args.log) app = Application(backend='uia').start(r'mspaint.exe') dlg = app.window(title_re='.* - Paint') # File->Open menu selection dlg.File_tab.click() dlg.child_window(title='Open', control_type='MenuItem', found_index=0).invoke() # handle Open dialog file_name_edit = dlg.Open.child_window(title="File name:", control_type="Edit") file_name_edit.set_text('walter_cat.jpg') # There are 2 Open buttons:
The example shows how to work with MS Paint application. It opens JPEG image and resizes it using "Resize and Skew" dialog. """ from __future__ import print_function import logging from pywinauto import actionlogger from pywinauto import Application import argparse parser = argparse.ArgumentParser() parser.add_argument("--log", help = "enable logging", type=str, required = False) args = parser.parse_args() actionlogger.enable() logger = logging.getLogger('pywinauto') if args.log: logger.handlers[0] = logging.FileHandler(args.log) app = Application(backend='uia').start(r'mspaint.exe') dlg = app.window(title_re='.* - Paint') # File->Open menu selection dlg.File_tab.click() dlg.child_window(title='Open', control_type='MenuItem', found_index=0).invoke() # handle Open dialog file_name_edit = dlg.Open.child_window(title="File name:", control_type="Edit") file_name_edit.set_text('walter_cat.jpg') # There are 2 Open buttons:
def test(): actionlogger.enable() nav = Navigation() nav.start() nav.setup_controls_and_dialogs() print('\ntest start') print('--------testing home ---------') y = nav.dialog['home'].menu() y.draw_outline() y = nav.dialog['home'].print() y.draw_outline() y = nav.dialog['home'].left_load() y.draw_outline() y = nav.dialog['home'].right_load() y.draw_outline() y = nav.dialog['home'].approve() y.draw_outline() y = nav.dialog['home'].retrieve() y.draw_outline() y = nav.dialog['home'].open_trash_bin() y.draw_outline() y = nav.dialog['home'].open_output_queue() y.draw_outline() y = nav.dialog['home'].test_list() y.draw_outline() print('--------testing approve ---------') y = nav.dialog['home'].approve() y.click() y = nav.dialog['approve'].home() y.draw_outline() y = nav.dialog['approve'].menu() y.draw_outline() y = nav.dialog['approve'].approve() y.draw_outline() y = nav.dialog['approve'].save() y.draw_outline() y = nav.dialog['approve'].test_list() y.draw_outline() y = nav.dialog['approve'].test_comment() y.draw_outline() y = nav.dialog['approve'].oos_comment() y.draw_outline() y = nav.dialog['approve'].general_comment() y.draw_outline() y = nav.dialog['approve'].mold_count() y.draw_outline() # broken y = nav.dialog['approve'].home() y.click() print('--------testing retrieve---------') y = nav.dialog['home'].retrieve() y.click() y = nav.dialog['retrieve'].home() y.draw_outline() y = nav.dialog['retrieve'].menu() y.draw_outline() y = nav.dialog['retrieve'].cancel() y.draw_outline() y = nav.dialog['retrieve'].retrieve() y.draw_outline() y = nav.dialog['retrieve'].trash() y.draw_outline() y = nav.dialog['retrieve'].test_list() y.draw_outline() y = nav.dialog['retrieve'].home() y.click() print('--------testing user roles---------') y = nav.dialog['home'].menu() y.click() y = nav.dialog['menu'].user_roles() y.click() y = nav.dialog['user_roles'].home() y.draw_outline() y = nav.dialog['user_roles'].menu() y.draw_outline() y = nav.dialog['user_roles'].new() y.draw_outline() y = nav.dialog['user_roles'].edit() y.draw_outline() y = nav.dialog['user_roles'].save() y.draw_outline() y = nav.dialog['user_roles'].delete() y.draw_outline() y = nav.dialog['user_roles'].cancel() y.draw_outline() ################################# y = nav.dialog['user_roles'].user_roles_list() y.draw_outline() ################################# y = nav.dialog['user_roles'].methods_create() y.draw_outline() y = nav.dialog['user_roles'].methods_edit() y.draw_outline() y = nav.dialog['user_roles'].methods_delete() y.draw_outline() y = nav.dialog['user_roles'].aa_create() y.draw_outline() y = nav.dialog['user_roles'].aa_edit() y.draw_outline() y = nav.dialog['user_roles'].aa_delete() y.draw_outline() y = nav.dialog['user_roles'].home() y.click() print('--------testing users---------') y = nav.dialog['home'].menu() y.click() y = nav.dialog['menu'].users() y.click() y = nav.dialog['users'].home() y.draw_outline() y = nav.dialog['users'].menu() y.draw_outline() y = nav.dialog['users'].new() y.draw_outline() y = nav.dialog['users'].edit() y.draw_outline() y = nav.dialog['users'].save() y.draw_outline() y = nav.dialog['users'].cancel() y.draw_outline() y = nav.dialog['users'].disable() y.draw_outline() ################################# y = nav.dialog['users'].users_list() y.draw_outline() ################################# y = nav.dialog['users'].first() y.draw_outline() y = nav.dialog['users'].middle() y.draw_outline() y = nav.dialog['users'].last() y.draw_outline() y = nav.dialog['users'].username() y.draw_outline() y = nav.dialog['users'].email() y.draw_outline() y = nav.dialog['users'].password_a() y.draw_outline() y = nav.dialog['users'].phone() y.draw_outline() y = nav.dialog['users'].password_b() y.draw_outline() y = nav.dialog['users'].extension() y.draw_outline() y = nav.dialog['users'].user_role_combo_box() y.draw_outline() #y = nav.dialog['users']. user_role_entry("Administrator") #y.draw_outline() ################################ y = nav.dialog['users'].methods_create() y.draw_outline() y = nav.dialog['users'].methods_edit() y.draw_outline() y = nav.dialog['users'].methods_delete() y.draw_outline() y = nav.dialog['users'].aa_create() y.draw_outline() y = nav.dialog['users'].aa_edit() y.draw_outline() y = nav.dialog['users'].aa_delete() y.draw_outline() y = nav.dialog['users'].home() y.click() print('test is done')