今天同事问了我一嘴,怎么实现GUI自动化,想起来以前用过的pywinauto,自己也玩了一把,好久没用了,生疏了哈哈哈
代码如下
from pywinauto.application import Application
import time
from pywinauto.findwindows import find_windows,find_elements
app=Application().start(r'C:\Users\XChen32\Desktop\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\1.exe')
time.sleep(5)
s=app.window(title='Form1')
time.sleep(2)
print(s.print_control_identifiers())
s['button2'].click()
ss=app.window(title='Form2')
#等待窗体可用 app.WindowSpecification.wait('enabled')
#from pywinauto.application import Application
#app = Application(backend="win32").start('executable')
#app.WindowSpecification.wait('enabled').type_keys('%i')
ss.wait('enabled')
print(ss.print_control_identifiers())
ss['Edit2'].type_keys('lllll')
ss['radioButton2'].click()
ss['ComboBox'].select('6')
#close
app.kill()
有价值的资料:
http://www.voidcn.com/article/p-cutlfesb-ha.html
https://www.apriorit.com/dev-blog/615-qa-gui-testing-windows-python-pywinauto
https://blog.csdn.net/shawpan/article/details/78170117
https://pywinauto.readthedocs.io/en/latest/getting_started.html
exe运行界面
程序执行效果