Python-selenium--File upload operation

Source: Internet
Author: User

One, file upload operation

Win32gui. FindWindow (Ipclassname,ipwindowname)

From the top-level window, start looking for the matching Criteria window and return the handle to the window;

Ipclassname: Class name, can be seen in Spy + +;

Ipwindowname: Window name, name you can see on the title bar

Win32gui. FindWindowEx (Hwndparent=0,hwndchildafter=0,ipszclassname=none,ipszwindowname=none)

The search for the class name and form name matches the form, and returns a handle to the form, which returns 0 if it is not found;

hWndParent: If not, then the search handle is hwndparent window subform;

Hwndchildafter: If not 0, the sub-form is searched backwards from hwndchildafter in the order of Z-index;

Ipszclassname: Character type, is the window's class name, this can be found in Spy + +;

Ipszwindowname: Character type, is the window name, that is, the title bar can see the title

Win32gui. SendMessage (Hwnd,msg,wparam,iparam)

HWnd: integer type, the window handle of receiving the message;

MSG: int, the message to be sent, these messages are all predefined by Windows;

WParam: integer type, wParam parameter of message;

Iparam: integer type, iparam parameter of message;

such as: Baidu Network disk upload operation-click the Upload button pop-up file box

#文件上传操作--command line installation python-m pip install Pypiwin32, reboot after installation Pycharm
Import Win32gui
Import Win32con
Import Time

#一级顶层窗口
dialog = Win32gui. FindWindow ("#32770", "open")
#二级窗口
comboBoxEx32 = Win32gui. FindWindowEx (dialog,0, "ComboBoxEx32", None)
#三级窗口
ComboBox = Win32gui. FindWindowEx (comboboxex32,0, "ComboBox", None)
#四级窗口--File path input area
edit = Win32gui. FindWindowEx (combobox,0, "Edit", None)

#二级窗口--Open button
button = Win32gui. FindWindowEx (dialog,0, "button", None)

#1, input file path
filepath = "E:\\chromedriver.exe"
Win32gui. SendMessage (Edit,win32con. Wm_settext,none,filepath)
Time.sleep (5)
#2, click the Open button
Win32gui. SendMessage (Dialog,win32con. Wm_command,1,button)

Python-selenium--File upload operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.