pywinauto win 自动化测试框架
1 # -*- coding: gb2312 -*- 2 __author__ = 'Zechary' 3 4 import time 5 from pywinauto import application 6 app = application.Application.start('notepad.exe') 7 app.Notepad.MenuSelect('帮助->关于记事本'.decode('gb2312')) 8 time.sleep(5) 9 10 about_dlg = app.window_(title_re = u"关于", class_name = "#32770") 11 about_dlg.print_control_identifiers() 12 #app.window_(title_re = u'关于“记事本”').window_(title_re = u'确定').Click() 13 #app.Notepad.MenuSelect('帮助->关于记事本'.decode('gb2312')) 14 time.sleep(5) 15 16 ABOUT = u'关于“记事本”' 17 OK = u'确定' 18 app[ABOUT][OK].Click() 19 20 #app.Notepad.TypeKeys(u"abcdefg") 21 dig = app.Notepad.MenuSelect("编辑(E)->替换(R)".decode('gb2312')) 22 Replace = u'替换' 23 Cancle = u'取消' 24 time.sleep(.5) 25 app[Replace][Cancle].Click() 26 27 dig = app.Notepad.MenuSelect("文件(F)->保存(S)".decode('gb2312')) 28 File = u'另存为' 29 Cancle = u'取消' 30 app[File][Cancle].Click() 31 32 dialogs = app.windows_()