pywinauto

pywinauto客户端自动化---pywinauto初始

回眸只為那壹抹淺笑 提交于 2020-08-15 23:16:20
  目前流行的自动化就是web,app,接口算是目前最主流的测试内容了,那么如果让做安装windows上的客户端自动化呢?是不是一脸懵?今天安静给大家介绍python的第三方库,可以帮助我们做客户端的自动化 pywinauto pywinauto是一组用于自动化Microsoft Windows GUI的python模块。 最简单的是,它允许您将鼠标和键盘操作发送到窗口对话框和控件,来完成我们自动化操作。 官方文档: http://pywinauto.github.io/ 安装: 方法一: 通过pip进行安装: pip install pywinauto 方法二: https://github.com/pywinauto/pywinauto/releases 中下载最新的pywinauto,解压并允许 python setup.py install 进行安装 验证是否安装成功: 方法一: 直接打开python,进行导入对应的库 方法二: 通过pip进行查看 pip list 小试牛刀 在练习之前,需要先了解一个内容,目前pywinauto支持2种查看客户端控件内容 Win32 API ( backend="win32" ) - 现在的默认backend MFC, VB6, VCL, 简单的WinForms控件和大多数旧的遗留应用程序 MS UI Automation (

pywinauto客户端自动化---窗口进行截图

…衆ロ難τιáo~ 提交于 2020-08-11 00:01:42
  做自动化过程中时长会遇到一些截图操作,那么在做客户端的时候,应该怎么进行截图呢? 窗口截图 在pywinauto中存在自带的截图函数 capture_as_image() 源码: def capture_as_image(self, rect= None): """ Return a PIL image of the control. See PIL documentation to know what you can do with the resulting image. """ control_rectangle = self.rectangle() if not (control_rectangle.width() and control_rectangle.height()): return None # PIL is optional so check first if not ImageGrab: print ( " PIL does not seem to be installed. " " PIL is required for capture_as_image " ) self.actions.log( " PIL does not seem to be installed. " " PIL is required for capture_as_image

pywinauto客户端自动化---窗口进行截图

不打扰是莪最后的温柔 提交于 2020-08-08 02:09:44
  做自动化过程中时长会遇到一些截图操作,那么在做客户端的时候,应该怎么进行截图呢? 窗口截图 在pywinauto中存在自带的截图函数 capture_as_image() 源码: def capture_as_image(self, rect= None): """ Return a PIL image of the control. See PIL documentation to know what you can do with the resulting image. """ control_rectangle = self.rectangle() if not (control_rectangle.width() and control_rectangle.height()): return None # PIL is optional so check first if not ImageGrab: print ( " PIL does not seem to be installed. " " PIL is required for capture_as_image " ) self.actions.log( " PIL does not seem to be installed. " " PIL is required for capture_as_image

pywinauto客户端自动化---窗口等待方法

…衆ロ難τιáo~ 提交于 2020-08-06 10:20:05
  我们在做web和app的ui自动化过程中,常用到等待机制,那客户端自动化有这个方法吗?python这么强大,肯定是有方法解决的 等待机制 pywinauto等待有两种方法: 方法一: wait() wait_for:表示可以选择窗口状态 timeout:超时时间 retry_interval:表示重试间隔 def wait(self, wait_for, timeout=None, retry_interval= None): """ 等待窗口处于特定的状态 * 'exists' 表示窗口是一个有效的句柄 * 'visible' 表示窗口不隐藏 * 'enabled' 表示该窗口未被禁用 * 'ready' 表示窗口可见并已启用 * 'active' 表示窗口处于活动状态 timeout:表示超时 retry_interval:表示重试间隔 """ check_method_names, timeout, retry_interval = self. __parse_wait_args (wait_for, timeout, retry_interval) wait_until(timeout, retry_interval, lambda : self. __check_all_conditions (check_method_names, retry_interval))

Delphi: Simulate key press for automation

余生长醉 提交于 2020-08-03 05:47:10
问题 I want to change text of an edit control of an external application. The application is written in Delphi. It has several forms. I started with Python libraries pywinauto + sendkeys to test the first form TLoginForm . It works perfectly. Here is the pseudo code: helper = pywinauto.application.Application() hwnd = pywinauto.findwindows.find_windows(class_name='TLoginForm')[0] window = helper.window_(handle=hwnd) ctrl = window[2] # the second control is the edit control I want to access ctrl

How to get a list of the name of every open window?

断了今生、忘了曾经 提交于 2020-05-10 18:40:09
问题 How do I get a list of the name/text of all opened windows? I tried pywinauto: pywinauto.findwindows.find_windows(title_re="*") but using * as a regex raises an error I tried win32gui: It has win32gui.GetWindowText(win32gui.GetForegroundWindow()) But in its docs I couldn't find a getAllWindows or something that returns all names/texts of open hwnd handles: http://timgolden.me.uk/pywin32-docs/contents.html 回答1: You can use win32gui.GetWindowText( hwnd ) along with win32gui.EnumWindows: import

How to get a list of the name of every open window?

99封情书 提交于 2020-05-10 18:38:31
问题 How do I get a list of the name/text of all opened windows? I tried pywinauto: pywinauto.findwindows.find_windows(title_re="*") but using * as a regex raises an error I tried win32gui: It has win32gui.GetWindowText(win32gui.GetForegroundWindow()) But in its docs I couldn't find a getAllWindows or something that returns all names/texts of open hwnd handles: http://timgolden.me.uk/pywin32-docs/contents.html 回答1: You can use win32gui.GetWindowText( hwnd ) along with win32gui.EnumWindows: import

Python 常用笔记

送分小仙女□ 提交于 2020-04-14 13:30:09
【推荐阅读】微服务还能火多久?>>> 记录 http://blog.sina.com.cn/s/ blog_73b339390102yoio.html PE:市盈率 = 股价 / 每股盈利 PEG:(市盈率相对盈利增长比率 /市盈增长比率) PEG=PE/(企业年盈利增长率*100 ) PB:市净率 =股价 / 每股净资产 PS:市销率 =股价 / 每股收入=总市值 / 销售收入 ROE:净资产收益率=报告期净利润/报告期末净资产 EPS:每股盈余 =盈余 / 流通在外股数 beta值:(贝塔系数):每股收益 =期末净利润 / 期末总股本 import math 年均投资收益率 = (pow(终值 /本金, 1/年限) -1)*100 投资收益本息 = pow((1+预期年收益率),年限)*本金 投资目标年限 = math.log(终值/本金)/math.log(1+预期年收益率) 时间转换 import time a = ' 2020-03-06 19:18:00 ' a1 = time.strptime(a, ' %Y-%m-%d %H:%M:%S ' ) # 格式化str为time格式 print (time.strftime( ' %Y%m%d ' ,a1)) # 格式化time格式为str print (time.asctime(time.localtime(time

Run Google Chrome With Proxy Using Pywinauto

陌路散爱 提交于 2020-03-05 06:04:12
问题 I want to run a google chrome window while specifying proxy I have tried something like this : chrome.start(chrome_dir + ' --force-renderer-accessibility --proxy-server=https://usr:pswd@proxy:port --incognito --start-maximized ' 'https://whatismyipaddress.com/') please help, I am using pywinauto on python 3 来源: https://stackoverflow.com/questions/60027951/run-google-chrome-with-proxy-using-pywinauto

How to select a sub menu from a context menu?

偶尔善良 提交于 2020-03-05 05:52:58
问题 I am trying to click on a sub menu(BTDecoder) item from a context menu(send to) using pywinauto. I could click on the menu item from context list and click on it. But when i try to click on sub menu, its not happening. its showing there is no item like that. Here is my code : path=os.path.realpath(path) os.startfile(path) # open the folder named "FW" app = pywinauto.Desktop(backend='uia').window(best_match='FW') win = app.window(title_re='WRT_FW_27_12_2018_11_19_59_000001') win.click_input