Exercise 5-python + selenium browser encounters pop-up window system, how to deal with

Some pages do interact with the page file upload time, and some will bring up the window system window to import certain files, this time with a simple python + selenium has been unable to meet this treatment

This time can be used to support other libraries, for this is the first time I encountered, so the record about a whole process yourself experience.

Tools: In order to better understand the window of a window controls, download the software to view the space: WinSpy-1.0.3.7z

 

See details of the window, to facilitate locating the correct position

 

 

 

 

The main code:

The main function of usage:

win32gui.FindWindow Function: This function gets a top-level window handle, this function does not find the child window. Case-insensitive when looking up.

handle = win32gui.FindWindow (class_name, window_title): class_name: window class, window_title: title of the window. Returns the result for the current window handle information

 

win32gui.FindWindowEx function: This function obtains a window handle, this function looks child window, starting at the back of a given sub-window in a child window

win32gui.FindWindowEx(handle,child,class_name,window_title):

handle: To find the parent window handle of the child window

child: the child window handle, if the parameter is 0, starting from the first child to find the window of the top floor window

class_name: class name

window_title: window name

 

win32gui.SendMessage(handle,Massage,wParam,lParam):

 

 

 

handle: receiving information window handle

Msg: To send a message, these messages are pre-defined windows

wParam: wParam parameter message

lParam: lParam parameter message

WM_SETTEXT message: Set the form of text, the wParam: not used, the lParam: variable name, the form is set to the text string.

win32api.SendMessage(Mhandle, win32con.WM_COMMAND, 1, confirmBTN_handle) :利用一个WM_COMMAND消息来点击确定按钮 

Guess you like

Origin www.cnblogs.com/yimihua-kai/p/12099208.html