When python uses selenium to download attachments, chrome and filefox can customize the download folder path, but IE cannot.
This is quite troublesome during automation. Many methods have been introduced on the Internet, which are quite troublesome.
The personal solution is as follows:
# IE save as path
def saveIeFile(self, filePath):
win32api.keybd_event(117,0,0,0) # F6
win32api.keybd_event(117,0, win32con.KEYEVENTF_KEYUP,0) # F6
time.sleep(0.5)
win32api.keybd_event(9,0,0,0) # TAB
win32api.keybd_event(9,0, win32con.KEYEVENTF_KEYUP,0) #Release button
time.sleep(0.5)
win32api.keybd_event(40,0,0,0) # DOWN
win32api.keybd_event(40,0, win32con.KEYEVENTF_KEYUP,0) #Release button
time.sleep(0.5)
win32api.keybd_event(65,0,0,0) # A
win32api.keybd_event(65,0, win32con.KEYEVENTF_KEYUP,0) # A
time.sleep(0.5)
autoit.control_set_text("Save as","Edit1", filePath)
time.sleep(1)
autoit.control_click("Save as","Button2")
This method is operated by keyboard and automatically saved as the relevant file path
Recommended Posts