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

相关推荐
田本初1 小时前
浏览器缓存与协商缓存
前端·javascript·缓存
微凉的衣柜1 小时前
在 PyTorch 中进行推理时,为什么 `model.eval()` 和 `torch.no_grad()` 需要同时使用?
人工智能·pytorch·python
int WINGsssss1 小时前
使用系统内NCCL环境重新编译Pytorch
人工智能·pytorch·python
孤单网愈云1 小时前
11.25Pytorch_手动构建模型实战
人工智能·pytorch·python
类人_猿2 小时前
ASP.NET Web(.Net Framework) Http服务器搭建以及IIS站点发布
前端·iis·asp.net·.net·http站点服务器
ZXF_H2 小时前
pip安装github上的开源软件包
git·python·github·pip
没事别学JAVA2 小时前
使用Python编写Windows系统服务管理脚本,主要用于管理mysql、postgresql等服务
windows·python
yivifu3 小时前
用python将一个扫描pdf文件改成二值图片组成的pdf文件
python·pdf·numpy·pillow·pymupdf
Eric.Lee20214 小时前
数据集-目标检测系列- 装甲车 检测数据集 armored_vehicles >> DataBall
python·算法·yolo·目标检测·装甲车检测
Eric.Lee20214 小时前
数据集-目标检测系列- 牵牛花 检测数据集 morning_glory >> DataBall
人工智能·python·yolo·目标检测·计算机视觉·牵牛花检测