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

相关推荐
三翼鸟数字化技术团队11 分钟前
Vue自定义指令最佳实践教程
前端·vue.js
The Future is mine13 分钟前
Python计算经纬度两点之间距离
开发语言·python
九月镇灵将16 分钟前
GitPython库快速应用入门
git·python·gitpython
Jasmin Tin Wei40 分钟前
蓝桥杯 web 学海无涯(axios、ecahrts)版本二
前端·蓝桥杯
圈圈编码1 小时前
Spring Task 定时任务
java·前端·spring
转转技术团队1 小时前
代码变更暗藏危机?代码影响范围分析为你保驾护航
前端·javascript·node.js
兔子的洋葱圈1 小时前
【django】1-2 django项目的请求处理流程(详细)
后端·python·django
Mintopia1 小时前
Node.js高级实战:自定义流与Pipeline的高效数据处理 ——从字母生成器到文件管道的深度解析
前端·javascript·node.js
Mintopia1 小时前
Three.js深度解析:InstancedBufferGeometry实现动态星空特效 ——高效渲染十万粒子的底层奥秘
前端·javascript·three.js
北凉温华1 小时前
强大的 Vue 标签输入组件:基于 Element Plus 的 ElTagInput 详解
前端