当前位置:网站首页>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)
边栏推荐
- IDEA公布全新默认UI,太清爽了(内含申请链接)
- 找到页面当前元素z-index最高的数值
- 提高用户体验 防御性编程
- Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
- 介绍两款代码自动生成器,帮助提升工作效率
- Redis——缓存击穿、穿透、雪崩
- 自学table au
- Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem
- 【程序员的自我修养]—找工作反思篇二
- Redis---1. Data structure characteristics and operation
猜你喜欢
Introduce two automatic code generators to help improve work efficiency
深入学习JVM底层(四):类文件结构
Sparse array (nonlinear structure)
最新CUDA环境配置(Win10 + CUDA 11.6 + VS2019)
CUDA中的线程层次
Redis - cluster data distribution algorithm & hash slot
pytest(2) mark功能
华为MindSpore开源实习机试题
Linear DP (split)
Common means of modeling: combination
随机推荐
CUDA中的动态全局内存分配和操作
CUDA用户对象
Redis---1. Data structure characteristics and operation
VLAN experiment of switching technology
Golang--map扩容机制(含源码)
ctf三计
Tensorrt command line program
Idea announced a new default UI, which is too refreshing (including the application link)
记录一次RDS故障排除--RDS容量徒增
递归(迷宫问题、8皇后问题)
ModuleNotFoundError: No module named ‘jieba.analyse‘; ‘jieba‘ is not a package
Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem
Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
CUDA中的Warp Shuffle
Sentinel rules persist to Nacos
The difference between session and cookies
深入学习JVM底层(四):类文件结构
In depth understanding of JUC concurrency (II) concurrency theory
In depth understanding of JUC concurrency (I) what is JUC
selenium的web自动化中常用的js-修改元素属性翻页