当前位置:网站首页>Uploading attachments using Win32 in Web Automation
Uploading attachments using Win32 in Web Automation
2022-07-02 06:33:00 【bthtth】
One Scenario as follows
In baidu home page ," Search by image " when , Need to upload pictures .
Two Tools and environments
1\ Need to install winspy This tool
2\ Need to install win32 library pip install pywin32
winspy Usage of
location
(1) Call the file upload window
(2) open winspy, single click " Aimed at " Shape button , Don't let go . Drag the button to the window element you want to locate , such as " file name " Input fields and " open " Button
(3) And then in winspy Fetch element class and Element text
If there is no text content ,cation It's empty
(4) View the hierarchical path of the element .
stay winspy Panel click "more"( Some versions are tree),
Click on "locate", Will show "edit" Path . Handle in turn \classname\ Text
You can see "edit" Altogether 4 Level path , And you can get the handle of each level of path \ Classes and text
Use pywin32 Finish uploading files
win32gui.FindWindow(IpClassName,IpWindowName)
ipclassname Elemental class ipwindowname caption
win32gui.FindWindowEX(hwndparent=0, hwndchildafter=0,ipszclass=None,ipszwindow=None)
Search for forms whose class name matches the text
hwndparent If not 0, Then the search handle is hwndparent Form
hwndchildafter If not 0, According to z-index Search in the order of hwndchildafter Subform of , Otherwise, search from the first subform
ipszclass class The name of
ipszwindow Form caption
win32gui.sendMessage(hwnd,msg,Wparame,Iparame)
hwnd: Handle to the form that accepts the message
msg: news , Pre existing windows Defined commands
wparame and iparame Unclear , For these two parameters, please refer to this article
wparame and iparame The explanation of
import win32gui
import win32con
# Get top-level window , Pass in the top-level window class and caption
dialog = win32gui.FindWindow("#32770"," Open file ")
# Get the secondary window
# Pass in the parent window ,0, window class and caption, If caption Use if it is empty None
ComboBoxEx32 = win32gui.FindWindowEx(dialog,0,"ComboBoxEx32",None)
# Get the three-level window
ComboBox = win32gui.FindWindowEx(ComboBoxEx32,0,"ComboBox",None)
# Get level 4 elements
edit = win32gui.FindWindowEx(ComboBox,0,"Edit",None)
# obtain " open " Button
button = win32gui.FindWindowEX(dialog,0,"Button"," open (&O)")
# " file name " Enter the file path
win32gui.sendmessage(edit,win32con.WM_SETTEXT,None," File path ")
# Click on " open "
win32gui.sendmessage(dialog,win32con.WM_CoMMANd,1,button)
边栏推荐
- RestTemplate请求时设置请求头,请求参数,请求体。
- CUDA and Direct3D consistency
- 利用传统方法(N-gram,HMM等)、神经网络方法(CNN,LSTM等)和预训练方法(Bert等)的中文分词任务实现
- Function execution space specifier in CUDA
- Redis---1.数据结构特点与操作
- 深入学习JVM底层(二):HotSpot虚拟机对象
- 自学table au
- qq邮箱接收不到jenkins构建后使用email extension 发送的邮件(timestamp 或 auth.......)
- ctf-web之练习赛
- 看完有用的blog
猜你喜欢
ctf三计
【张三学C语言之】—深入理解数据存储
Sentinel规则持久化到Nacos
Alibaba cloud MFA binding Chrome browser
日志(常用的日志框架)
Pbootcms collection and warehousing tutorial quick collection release
Detailed definition of tensorrt data format
New version of dedecms collection and release plug-in tutorial tool
CUDA中的Warp Shuffle
TensorRT的数据格式定义详解
随机推荐
AWD学习
Hydration failed because the initial UI does not match what was rendered on the server.问题原因之一
Log (common log framework)
Kotlin - 验证时间格式是否是 yyyy-MM-dd HH:mm:ss
Redis——Cluster数据分布算法&哈希槽
selenium的web自动化中常用的js-修改元素属性翻页
日志 - 7 - 记录一次丢失文件(A4纸)的重大失误
FE - weex 开发 之 使用 weex-ui 组件与配置使用
实习生跑路留了一个大坑,搞出2个线上问题,我被坑惨了
Sudo right raising
web自动中利用win32上传附件
Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
qq邮箱接收不到jenkins构建后使用email extension 发送的邮件(timestamp 或 auth.......)
(第一百篇BLOG)写于博士二年级结束-20200818
Distributed transactions: the final consistency scheme of reliable messages
Sentinel Alibaba open source traffic protection component
利用传统方法(N-gram,HMM等)、神经网络方法(CNN,LSTM等)和预训练方法(Bert等)的中文分词任务实现
The difference between session and cookies
Summary of advertisement business bug replay
DeprecationWarning: .ix is deprecated. Please use.loc for label based indexing or.iloc for positi