Python-Selenium-使用 pywinauto 实现 Input 上传文件

当前环境:Win10 + Python3.7 + pywinauto==0.6.8,selenium==3.14.1

示例代码

python 复制代码
from pywinauto import Desktop
import os

app = Desktop()
dialog = app['打开']
dialog['Edit'].set_edit_text(os.getcwd() + '.\\example-01.jpg')
dialog['Button'].click()


'''
其他方法:
from pywinauto import application
import os

app = application.Application()
app.connect(title='打开')
# app['Dialog']['Edit1'].type_keys(os.getcwd() + '.\\example-01.jpg')
# app['Dialog']['Edit1'].SetEditText(os.getcwd() + '.\\example-01.jpg')
app['Dialog']['Edit1'].set_edit_text(os.getcwd() + '.\\example-01.jpg')

app['Dialog']['Button1'].click()
'''

参考:

https://mp.weixin.qq.com/s?__biz=MzU1NzgyNDI3NQ==\&mid=2247484679\&idx=1\&sn=a340747f16f0c5697764ede7f448a63d\&chksm=fc2ea57bcb592c6da51fd3f186a557ac29994bb78b919c618f17ae10fbbdfb16d7c8230e427a\&mpshare=1\&scene=1\&srcid=1216DMzWHdhTgZYFFbVGZHsW\&sharer_shareinfo=c65396678acf6d09bcf06fc57ed0addd\&sharer_shareinfo_first=c65396678acf6d09bcf06fc57ed0addd\&exportkey=n_ChQIAhIQduawNpbBAqP4iyR8%2FYTAShLyAQIE97dBBAEAAAAAAM%2FgFUW0vVIAAAAOpnltbLcz9gKNyK89dVj0DOxgVp8EciivdLsqOeEOeDn%2FVPMouyiXKMKo40Fk76NmX8%2B9UecOMBQOLNgS3oM3USy95IGseYWfWmx08Blkzlyllc0Fobk7aCaaipck4W8pJ%2BLJX6rD5iywpWQwG6vffOs6llL8yGnU6e30ZjFrjPV9IILsurSLzrVbglwwjtgTOb1FpTslaJw4PK6nBzF4Qos2x0Zj9%2FSFKiEKhPosme7v7ePriXmNDr7iQFaEOlp4p5f69wL9O1BWV0CY6ovevQu2D9r1iYKzjsn1\&acctmode=0\&pass_ticket=gc%2Bk84qheb1bQ6ScSF35lH7APcEXiU415dFWdmHHbPZqiETZGvHPyD4ZC2OJMHN7hRX2TdXRrFc16LrLv0llyg%3D%3D\&wx_header=0#rd

https://mp.weixin.qq.com/s?__biz=MjM5NTU0MDg0MA==\&mid=2651267611\&idx=1\&sn=c1ae1a4a17b1c63c18dc223d8ba23af3\&chksm=bd05781c8a72f10a81cf6239044a6354d9137f8e322dcea9383852f90c89fb3b554eb766eb94\&mpshare=1\&scene=1\&srcid=12164RziUu8kd3yryjnvtZbU\&sharer_shareinfo=8f38390e1fc6e5b07aaa3bd8c3e68f07\&sharer_shareinfo_first=8f38390e1fc6e5b07aaa3bd8c3e68f07\&exportkey=n_ChQIAhIQrwmNtaFAKwU0xpCrjCRctRLyAQIE97dBBAEAAAAAAHDQCsJVPy0AAAAOpnltbLcz9gKNyK89dVj0MmfYFIQO3IjAltC9jzxNXjdYR%2F31Ok%2BvtyLtDB6OaZNw%2BGBsHYRd%2BsXSUrbrXLC1ONnJ%2FPAiluSRe0iQILwcgzD8LboFF%2F8YfhIBFIAVsAYDAJfNzFpstvgOkiXf0PZsuw1p%2Bg3M7N25llXF7VQ21%2FDqePZcYMEc7JXRtEfo1%2BkWgf1VJU%2Bp9SA8EuCaSu1Tbb3CXWb0Fy%2FwCDld8LB9zJ%2FppHyc9dG6uIdBES8AiHoZDHwHkYHGvhpjrlf8ZOpDjH%2BsVwa%2BIFR0ulX2\&acctmode=0\&pass_ticket=gc%2Bk84qheb1bQ6ScSF35lH7APcEXiU415dFWdmHHbPZoefKqE%2BuBGd4YY3MF66ov5%2FCbx0d5wkGWluKyPGNFrA%3D%3D\&wx_header=0#rd

https://www.qiniu.com/qfans/qnso-60569025

相关推荐
q567315239 分钟前
在 Bash 中获取 Python 模块变量列
开发语言·python·bash
是萝卜干呀10 分钟前
Backend - Python 爬取网页数据并保存在Excel文件中
python·excel·table·xlwt·爬取网页数据
代码欢乐豆11 分钟前
数据采集之selenium模拟登录
python·selenium·测试工具
吕彬-前端25 分钟前
使用vite+react+ts+Ant Design开发后台管理项目(五)
前端·javascript·react.js
学前端的小朱27 分钟前
Redux的简介及其在React中的应用
前端·javascript·react.js·redux·store
guai_guai_guai36 分钟前
uniapp
前端·javascript·vue.js·uni-app
狂奔solar1 小时前
yelp数据集上识别潜在的热门商家
开发语言·python
Tassel_YUE1 小时前
网络自动化04:python实现ACL匹配信息(主机与主机信息)
网络·python·自动化
聪明的墨菲特i1 小时前
Python爬虫学习
爬虫·python·学习
bysking2 小时前
【前端-组件】定义行分组的表格表单实现-bysking
前端·react.js