实例介绍
pywinauto说明文档,国内没有啊~~~
Contents 1 What is pywinauto 1.1 What is it? 12 Installation 1. 3 Manual installation 1. 4 How does it work 1. 5 Some similar tools for comparison 1.6 Why write yet another automation tool if there are so many out there? 2 2 Getting Started Guide 2. 1 GUI Objects Inspection 2.2 Entry Points for Automation 556 2.3 Window Specification 6 2. 4 Attribute resolution magic 7 2.5 How to know magic attribute names 7 2.6 Look at the examples 10 2.7 Automate notepad at the command line 10 3HowT’s 13 3.1 How to specify a usable Application instance 13 3.2 How to specify a dialog of the application .14 3.3 How to specify a control on a dialog 14 3.4 How to use pywinauto with application languages other than English 16 3.5 How to deal with controls that do not respond as expected (e. g. OwnerDraw Controls) 17 3.6 How to Access the System Tray(aka SysTray, aka "Notification Area) 18 4 Waiting for Long Operations 9 4. 1 Application methods 19 4.2 Window Specification methods 19 4.3 Functions in timings module 4.4 Identify controls 20 5 Methods available to each different control type 21 5.1 All Controls 21 5.2 Button, CheckBox, RadioButton, GroupBox 5.3 Combobox 23 5.4 Dialo 23 5.5 Edit 23 5.6 Header ....24 5.7Li 24 5.8 List 24 5.9 PopupMenu 25 5.10 ReB 5 5.11 Static 25 5. 12 Status Bar 2 5.13 TabC 25 5.14 Tool · 26 5.15 TOOTI 26 5.16 Tree 26 5.17 UpD 7 6 Credits 29 7 Dey notes 31 7.1 FILE LAYOUT 31 7.2 Best matching 7.3 ATTRIBUTE RESOLUTION 32 7. 4 WRITING TO DIALOGS 8 PYWINAUTO TODO’s 35 8.1 CLOSED (in some way or the other 37 9 Change Log 39 9. 1 0.6.2 More bug fixes .39 9.2 0.6.1 Bug fixes and optimizations for UI Automation and beyond 39 9.3 0.6.0 Introduce MS UI Automation support and many more improvements 40 9.4 0.5.4 Bug fixes and partial MFC Menu Bar support 40 9.5 0.5.3 Better Unicode support for SetEditText/Type Keys and menu items 9.6 0.5.2 Improve List View, new methods for CPU usage, DPI awareness 9.70.5.1 Several fixes. more tests 9.8 0.5.0 64-bit Py 2/Py3 compatibility .42 9.9 0.4.0 Various cleanup and bug fixes 42 9.10 0.3.9 Experimental! New Sendkeys, and various fixes 9. 11 0.3.8 Collecting improvements from last 2 years 43 9. 12 0.3.7 Merge of Wait changes and various bug fixes/improvements 9. 13 0.3.6b Changes not documented in 0.3.6 history 45 9. 14 0.3.6 Scrolling and Review Item Clicking added 45 9.15 0.3.5 Moved to Metaclass control wrapping 45 9.16 0.3.4 Fixed issue with latest ctypes, speed gains, other changes 46 9.17. 3 Added some methods. and fixed some small bugs 9. 18 0.3.2 Fixed setup. py and some typos .47 9.19 0.3.1 Performance tune-ups 47 9.20 0.3.0 Added Application data- now useful for localization testing .................. 47 9.21 0.2.5 More refactoring, more tests 9.22 0.2.1 Small Release number- big changes 9.23 0.2.0 Significant refactoring 50 9.24 0.1.3 Many changes, few visible 9.25 0.1.2 Add Readme and rollup various changes 9.26 0.1.1 Minor bug fix release ..52 9. 270.1.0 Initial Release 52 10 Source code reference 53 10.1 Basic User Input Modules ...53 10.2 Main user modules 54 10.3 Specific Functionality 10.6 Backend Internal Implementation modules 10.4 Controls reference 65 10.5 Pre-supplied Tests 118 10.7 Internal modules .122 l1 Indices and table 127 Python Module Index 129 CHAPTER What is pywinauto OMarkMcMahonandContributors(https:/github.com/pywinauto/pywinauto/graphs/contributors),2006-2016 Released under the bsd 3-clause license What is it? pywinauto is a set of python modules to automate the microsoft Windows gul. At it's simplest it allows you to send mouse and keyboard actions to windows dialogs and controls nstallation Just pip install pywinauto Manual installation Install the following Python packages pyWin32(http:/sourceforge.net/projects/pywin32/files/pywin32/build%202201) comtypes(https://github.com/enthought/comtypes/releases) six(https://pypipython.org/pypi/six) (optional)pillow(https://pypi.pythonorg/pypi/pillow/2.7.0)(tomakescreenshoots) Downloadlatestpywinautofromhttps:/github.com/pywinauto/pywinauto/releases Unpack and run python setup. py install To check you have it installed correctly Run Python >> from pywinauto application import Application >> app- Application(backend-uia"). start(notepad. exe") >> app. UntitledNotepad type keys("2FX") ywinauto Documentation, Release 0.6.2 How does it work A lot is done through attribute access( getattribute )for each class. For example when you get the attribute of an Application or Dialog object it looks for a dialog or control(respectively) myapp. Nctepad looks for a window/Dialog of your app that has a title 'similar i LO NOLoad myapp. Pagesetup OK looks first for a dialog with a title like Pagesetup f then it looks tor a control on that dialog with a title Iike OK n This attribute resolution is delayed (with a default timeout) until it succeeds. So for example if you select a menu option and then look for the resulting dialog e. g app. UntitledNotepad menu_select( File->saveAs) app. SaveAs. ComboBox5 select(UTF-8) app. SaveAseditI settext("Example-utf8txt" app. SaveAs Save. click() At the 2nd line the saveAs dialog might not be open by the time this line is executed So what happens is that we wait until we have a control to resolve before resolving the dialog. At that point if we cant find a SaveAs dialog with ComboBox5 control then we wait a very short period of time and try again, this is repeated up to a maximum time (currently 5 seconds!) This is to avoid having to use time. sleep or a"wait function explicitly If your application performs long time operation, new dialog can appear or disappear later. You can wait for its new state like so app.Open Open. click()# opening large file pp Open. wait_ not (visible)# make sure " Open dialog became invisible wait for up to 30 seconds until data. txt is loaded app. window(title= data -xt Notepad).wait(ready, timeout-30) Some similar tools for comparison Python tools PyautoguI(https:/github.com/asweigart/pyautogui)-apopularcross-platformlibrary(hasimage-based search, no text-based controls manipulation) Lackey(https:/github.com/glitchassassin/lackey)-apurePythonreplacementforSikuli(basedonimage pattern matching) Axui(Https: /github. com/xcgspring/axut)-one of the wrappers around Ms Ui Automation Api winguiauto(https:/github.com/arkottke/winguiauto)-anothernoduleusingWin32Api Other scripting language tools (peRl)win32: : uitest(Http: //winguitest. sourceforge. net (ruBy)win32-autogui(httPs: /github. com/robertwahler/win32-autogui)-a wrapper around win32 Api (ruBy)rautomation(httPs:/github.com/jarmo/rautomation)-thereare3adaptersWin32Api,Uia Autoit Other free tools Chapter 1. What is pywinauto pywinauto Documentation, Release 0.6.2 (c#)winium.DEsktop(https:/github.com/2gis/winium.Desktop)-ayoungbutgoodMsUiAutomation based tool (c#F)teststack.White(https:/github.com/teststack/wHite)-anothErgoodMsUIAutomationbasedli- brary with a long history Autolt(http://www.autoitscript.com/)-freetoolwithitsownBasic-likelanguage(win32Apibased,no NET plans Autohotkey(httPs:/github.com/lexikos/autOhotkey_l/)-nativeC++toolwithitsownscriptinglan guage (ahk) awesOmetestautomation"list(https:/github.com/atinfo/awesome-test-automation)onGithub abiglistofopensourcetoolsforfunctionaltesting(http://www.opensourcetesting.org/category/functionaln) · Commercial tools Winrunner(hTtp://www.mercury.com/us/products/quality-center/functional-testing/winrunner/) Silktest(htTp://www.segue.com/products/functional-regressional-testing/silktest.asp) Manyothers(hllp://www.testinglags.org/-gui.htnl) Why write yet another automation tool if there are so many out there? There are loads of reasons: - Takes a different approach: Most other tools are not object oriented you end up writing stuff like window= findwindow(title ="Untitled- Notepad", class =Notepad") SendKeys(window, OF") Format - Font fotdialog findwindow(tile ="font buttonClick(fcntdialog, OK") I was hoping to create something more userfriendly(and pythonic). For example the translation of above would app. Untitlednotepad in menu select(Format->Fon=) app. Font. OK. click() Python makes it easy: Python is a great programming language, but there are no automation tools that were Pythonic (the very few libraries were implemented in Python) Localization as a main requirement: Mark I work in the localization industry and gui automation is used extensively as often all you need to do is ensure that your Ui behaves and is correct with respect to the Source UI. This is actually an easier job then for testing the original source U But most automation tools are based off of coordinates or text of the controls and these can change in the ocalized software. So my goal( though not yet implemented) is to allow scripts to run unchanged between original source language(often English) and the translated software(Japanese, German, etc) 1.6. Why write yet another automation tool if there are so many out there? 3 ywinauto Documentation, Release 0.6.2 Chapter 1. What is pywinauto 【实例截图】
【核心代码】
标签:
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论