python 自动化之pywinauto 安装
2016-12-10 22:38
489 查看
http://blog.sina.com.cn/s/blog_812973c30101snoj.html
官网文档
http://pywinauto.googlecode.com/hg/pywinauto/docs/index.html
Download pywinauto from https://sourceforge.net/project/showfiles.php?group_id=157379
Unzip the pywinauto zip file to a folder.
Run cd到 pywinauto-0.4.2 目录下,执行 python.exe setup.py install
Install the following Python packages
Optional PIL http://www.pythonware.com/products/pil/index.htm
Optional elementtree http://effbot.org/downloads/
Releases prior to 0.3.9 requireSendkeys- http://www.rutherfurd.net/python/sendkeys/index.html
If you are using Python 2.3 or 2.4 then you will have to installctypes http://starship.python.net/crew/theller/ctypes/(download
from http://sourceforge.net/project/showfiles.php?group_id=71702)
To check you have it installed correctly Run Python
from pywinauto import Application
import time
app = Application.start("notepad")
app.__setattr__("name","notepad")
time.sleep(2)
app.Notepad.edit.TypeKeys('Test ......................')
app.Notepad.edit.TypeKeys('Test ......................')
time.sleep(2)
#中文版本操作
app.Notepad.MenuSelect(u"文件(F)->另存为(A)...")
app.Dialog.edit.TypeKeys(u'TestFile.txt')
time.sleep(2)
#点击保存
app.Dialog.Button1.Click()
time.sleep(2)
#文件存在的话,要覆盖,所以再一次点击是
app.Dialog.Button1.Click()
time.sleep(1)
#退出notepad
app.Notepad.Close()
转自http://www.51testing.com/html/85/132585-852513.html
官网上的都是在英文环境下做的测试。在中文环境下 需要在代码前面加 #coding=gb2312 以下是完整官网类似代码
#coding=gb2312
from pywinauto import application
app = application.Application()
app.start_('notepad')
app.Notepad.MenuSelect('帮助->关于记事本'.decode('gb2312'))
官网文档
http://pywinauto.googlecode.com/hg/pywinauto/docs/index.html
安装依赖包
Download pywinauto from https://sourceforge.net/project/showfiles.php?group_id=157379Unzip the pywinauto zip file to a folder.
Run cd到 pywinauto-0.4.2 目录下,执行 python.exe setup.py install
Install the following Python packages
Optional PIL http://www.pythonware.com/products/pil/index.htm
Optional elementtree http://effbot.org/downloads/
Releases prior to 0.3.9 requireSendkeys- http://www.rutherfurd.net/python/sendkeys/index.html
If you are using Python 2.3 or 2.4 then you will have to installctypes http://starship.python.net/crew/theller/ctypes/(download
from http://sourceforge.net/project/showfiles.php?group_id=71702)
To check you have it installed correctly Run Python
实现NOTEPAD自动化写及保存
from pywinauto import Applicationimport time
app = Application.start("notepad")
app.__setattr__("name","notepad")
time.sleep(2)
app.Notepad.edit.TypeKeys('Test ......................')
app.Notepad.edit.TypeKeys('Test ......................')
time.sleep(2)
#中文版本操作
app.Notepad.MenuSelect(u"文件(F)->另存为(A)...")
app.Dialog.edit.TypeKeys(u'TestFile.txt')
time.sleep(2)
#点击保存
app.Dialog.Button1.Click()
time.sleep(2)
#文件存在的话,要覆盖,所以再一次点击是
app.Dialog.Button1.Click()
time.sleep(1)
#退出notepad
app.Notepad.Close()
转自http://www.51testing.com/html/85/132585-852513.html
官网上的都是在英文环境下做的测试。在中文环境下 需要在代码前面加 #coding=gb2312 以下是完整官网类似代码
#coding=gb2312
from pywinauto import application
app = application.Application()
app.start_('notepad')
app.Notepad.MenuSelect('帮助->关于记事本'.decode('gb2312'))
相关文章推荐
- Python+opencv3.0配置
- 数字
- Python3实现求质因数
- Python基础语法以及在windows下如何导入模块
- Python实现判断强密码
- 用python画箱体图-python学习笔记21
- python优雅实现适配器
- 用python画直方图--python学习笔记20
- 从零开始学Python07作业源码:虚拟人生(仅供参考)
- Python实现简单的Web完整版(一)
- 用python拍饼图--学习笔记19
- 给深度学习入门者的Python快速教程 - 基础篇
- Python
- Python 使用xlrd读Excel文件报错
- Python学习笔记(7)-函数
- Install OpenCV 3.0 and Python 2.7+ on OSX
- python __getattr__ 与 __call__
- Install OpenCV 3.0 and Python 2.7+ on Ubuntu
- 帕累托分布图--python学习笔记18
- python标准库